Skip to content

Commit fbdd3b2

Browse files
committed
sync: Rename arc::Condvar to arc::ArcCondvar.
The sync submodule also has a `Condvar` type, and its reexport was shadowing the `arc` type, making it crate-private.
1 parent 859277d commit fbdd3b2

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/libsync/arc.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ use std::kinds::marker;
4949
use std::sync::arc::UnsafeArc;
5050
use std::task;
5151

52-
/// As sync::condvar, a mechanism for unlock-and-descheduling and signaling.
53-
pub struct Condvar<'a> {
52+
/// As sync::condvar, a mechanism for unlock-and-descheduling and
53+
/// signaling, for use with the Arc types.
54+
pub struct ArcCondvar<'a> {
5455
priv is_mutex: bool,
5556
priv failed: &'a bool,
5657
priv cond: &'a sync::Condvar<'a>
5758
}
5859

59-
impl<'a> Condvar<'a> {
60+
impl<'a> ArcCondvar<'a> {
6061
/// Atomically exit the associated Arc and block until a signal is sent.
6162
#[inline]
6263
pub fn wait(&self) { self.wait_on(0) }
@@ -219,14 +220,14 @@ impl<T:Send> MutexArc<T> {
219220

220221
/// As access(), but with a condvar, as sync::mutex.lock_cond().
221222
#[inline]
222-
pub fn access_cond<U>(&self, blk: |x: &mut T, c: &Condvar| -> U) -> U {
223+
pub fn access_cond<U>(&self, blk: |x: &mut T, c: &ArcCondvar| -> U) -> U {
223224
let state = self.x.get();
224225
unsafe {
225226
(&(*state).lock).lock_cond(|cond| {
226227
check_poison(true, (*state).failed);
227228
let _z = PoisonOnFail::new(&mut (*state).failed);
228229
blk(&mut (*state).data,
229-
&Condvar {is_mutex: true,
230+
&ArcCondvar {is_mutex: true,
230231
failed: &(*state).failed,
231232
cond: cond })
232233
})
@@ -345,15 +346,15 @@ impl<T:Freeze + Send> RWArc<T> {
345346
/// As write(), but with a condvar, as sync::rwlock.write_cond().
346347
#[inline]
347348
pub fn write_cond<U>(&self,
348-
blk: |x: &mut T, c: &Condvar| -> U)
349+
blk: |x: &mut T, c: &ArcCondvar| -> U)
349350
-> U {
350351
unsafe {
351352
let state = self.x.get();
352353
(*borrow_rwlock(state)).write_cond(|cond| {
353354
check_poison(false, (*state).failed);
354355
let _z = PoisonOnFail::new(&mut (*state).failed);
355356
blk(&mut (*state).data,
356-
&Condvar {is_mutex: false,
357+
&ArcCondvar {is_mutex: false,
357358
failed: &(*state).failed,
358359
cond: cond})
359360
})
@@ -481,7 +482,7 @@ impl<'a, T:Freeze + Send> RWWriteMode<'a, T> {
481482

482483
/// Access the pre-downgrade RWArc in write mode with a condvar.
483484
pub fn write_cond<U>(&mut self,
484-
blk: |x: &mut T, c: &Condvar| -> U)
485+
blk: |x: &mut T, c: &ArcCondvar| -> U)
485486
-> U {
486487
match *self {
487488
RWWriteMode {
@@ -491,7 +492,7 @@ impl<'a, T:Freeze + Send> RWWriteMode<'a, T> {
491492
} => {
492493
token.write_cond(|cond| {
493494
unsafe {
494-
let cvar = Condvar {
495+
let cvar = ArcCondvar {
495496
is_mutex: false,
496497
failed: &*poison.flag,
497498
cond: cond
@@ -915,7 +916,7 @@ mod tests {
915916
// rwarc gives us extra shared state to help check for the race.
916917
// If you want to see this test fail, go to sync.rs and replace the
917918
// line in RWLock::write_cond() that looks like:
918-
// "blk(&Condvar { order: opt_lock, ..*cond })"
919+
// "blk(&ArcCondvar { order: opt_lock, ..*cond })"
919920
// with just "blk(cond)".
920921
let x = RWArc::new(true);
921922
let (wp, wc) = Chan::new();

src/libsync/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#[crate_type = "dylib"];
1818
#[license = "MIT/ASL2"];
1919

20-
pub use arc::{Arc, MutexArc, RWArc, RWWriteMode, RWReadMode, Condvar, CowArc};
20+
pub use arc::{Arc, MutexArc, RWArc, RWWriteMode, RWReadMode, ArcCondvar, CowArc};
2121
pub use sync::{Mutex, RWLock, Condvar, Semaphore, RWLockWriteMode,
2222
RWLockReadMode, Barrier, one, mutex};
2323
pub use comm::{DuplexStream, SyncChan, SyncPort, rendezvous};

0 commit comments

Comments
 (0)