@@ -49,14 +49,15 @@ use std::kinds::marker;
49
49
use std:: sync:: arc:: UnsafeArc ;
50
50
use std:: task;
51
51
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 > {
54
55
priv is_mutex : bool ,
55
56
priv failed : & ' a bool ,
56
57
priv cond : & ' a sync:: Condvar < ' a >
57
58
}
58
59
59
- impl < ' a > Condvar < ' a > {
60
+ impl < ' a > ArcCondvar < ' a > {
60
61
/// Atomically exit the associated Arc and block until a signal is sent.
61
62
#[ inline]
62
63
pub fn wait ( & self ) { self . wait_on ( 0 ) }
@@ -219,14 +220,14 @@ impl<T:Send> MutexArc<T> {
219
220
220
221
/// As access(), but with a condvar, as sync::mutex.lock_cond().
221
222
#[ 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 {
223
224
let state = self . x . get ( ) ;
224
225
unsafe {
225
226
( & ( * state) . lock ) . lock_cond ( |cond| {
226
227
check_poison ( true , ( * state) . failed ) ;
227
228
let _z = PoisonOnFail :: new ( & mut ( * state) . failed ) ;
228
229
blk ( & mut ( * state) . data ,
229
- & Condvar { is_mutex : true ,
230
+ & ArcCondvar { is_mutex : true ,
230
231
failed : & ( * state) . failed ,
231
232
cond : cond } )
232
233
} )
@@ -345,15 +346,15 @@ impl<T:Freeze + Send> RWArc<T> {
345
346
/// As write(), but with a condvar, as sync::rwlock.write_cond().
346
347
#[ inline]
347
348
pub fn write_cond < U > ( & self ,
348
- blk: |x: & mut T , c : & Condvar | -> U )
349
+ blk: |x: & mut T , c : & ArcCondvar | -> U )
349
350
-> U {
350
351
unsafe {
351
352
let state = self . x . get ( ) ;
352
353
( * borrow_rwlock ( state) ) . write_cond ( |cond| {
353
354
check_poison ( false , ( * state) . failed ) ;
354
355
let _z = PoisonOnFail :: new ( & mut ( * state) . failed ) ;
355
356
blk ( & mut ( * state) . data ,
356
- & Condvar { is_mutex : false ,
357
+ & ArcCondvar { is_mutex : false ,
357
358
failed : & ( * state) . failed ,
358
359
cond : cond} )
359
360
} )
@@ -481,7 +482,7 @@ impl<'a, T:Freeze + Send> RWWriteMode<'a, T> {
481
482
482
483
/// Access the pre-downgrade RWArc in write mode with a condvar.
483
484
pub fn write_cond < U > ( & mut self ,
484
- blk: |x: & mut T , c : & Condvar | -> U )
485
+ blk: |x: & mut T , c : & ArcCondvar | -> U )
485
486
-> U {
486
487
match * self {
487
488
RWWriteMode {
@@ -491,7 +492,7 @@ impl<'a, T:Freeze + Send> RWWriteMode<'a, T> {
491
492
} => {
492
493
token. write_cond ( |cond| {
493
494
unsafe {
494
- let cvar = Condvar {
495
+ let cvar = ArcCondvar {
495
496
is_mutex : false ,
496
497
failed : & * poison. flag ,
497
498
cond : cond
@@ -915,7 +916,7 @@ mod tests {
915
916
// rwarc gives us extra shared state to help check for the race.
916
917
// If you want to see this test fail, go to sync.rs and replace the
917
918
// line in RWLock::write_cond() that looks like:
918
- // "blk(&Condvar { order: opt_lock, ..*cond })"
919
+ // "blk(&ArcCondvar { order: opt_lock, ..*cond })"
919
920
// with just "blk(cond)".
920
921
let x = RWArc :: new ( true ) ;
921
922
let ( wp, wc) = Chan :: new ( ) ;
0 commit comments