@@ -56,10 +56,10 @@ pub struct Condvar<'self> {
56
56
cond : & ' self sync:: Condvar < ' self >
57
57
}
58
58
59
- pub impl < ' self > Condvar < ' self > {
59
+ impl < ' self > Condvar < ' self > {
60
60
/// Atomically exit the associated ARC and block until a signal is sent.
61
61
#[ inline( always) ]
62
- fn wait ( & self ) { self . wait_on ( 0 ) }
62
+ pub fn wait ( & self ) { self . wait_on ( 0 ) }
63
63
64
64
/**
65
65
* Atomically exit the associated ARC and block on a specified condvar
@@ -68,7 +68,7 @@ pub impl<'self> Condvar<'self> {
68
68
* wait() is equivalent to wait_on(0).
69
69
*/
70
70
#[ inline( always) ]
71
- fn wait_on ( & self , condvar_id : uint ) {
71
+ pub fn wait_on ( & self , condvar_id : uint ) {
72
72
assert ! ( !* self . failed) ;
73
73
self . cond . wait_on ( condvar_id) ;
74
74
// This is why we need to wrap sync::condvar.
@@ -77,28 +77,28 @@ pub impl<'self> Condvar<'self> {
77
77
78
78
/// Wake up a blocked task. Returns false if there was no blocked task.
79
79
#[ inline( always) ]
80
- fn signal ( & self ) -> bool { self . signal_on ( 0 ) }
80
+ pub fn signal ( & self ) -> bool { self . signal_on ( 0 ) }
81
81
82
82
/**
83
83
* Wake up a blocked task on a specified condvar (as
84
84
* sync::cond.signal_on). Returns false if there was no blocked task.
85
85
*/
86
86
#[ inline( always) ]
87
- fn signal_on ( & self , condvar_id : uint ) -> bool {
87
+ pub fn signal_on ( & self , condvar_id : uint ) -> bool {
88
88
assert ! ( !* self . failed) ;
89
89
self . cond . signal_on ( condvar_id)
90
90
}
91
91
92
92
/// Wake up all blocked tasks. Returns the number of tasks woken.
93
93
#[ inline( always) ]
94
- fn broadcast ( & self ) -> uint { self . broadcast_on ( 0 ) }
94
+ pub fn broadcast ( & self ) -> uint { self . broadcast_on ( 0 ) }
95
95
96
96
/**
97
97
* Wake up all blocked tasks on a specified condvar (as
98
98
* sync::cond.broadcast_on). Returns Returns the number of tasks woken.
99
99
*/
100
100
#[ inline( always) ]
101
- fn broadcast_on ( & self , condvar_id : uint ) -> uint {
101
+ pub fn broadcast_on ( & self , condvar_id : uint ) -> uint {
102
102
assert ! ( !* self . failed) ;
103
103
self . cond . broadcast_on ( condvar_id)
104
104
}
@@ -120,8 +120,8 @@ pub fn ARC<T:Const + Owned>(data: T) -> ARC<T> {
120
120
* Access the underlying data in an atomically reference counted
121
121
* wrapper.
122
122
*/
123
- pub impl < T : Const +Owned > ARC < T > {
124
- fn get < ' a > ( & ' a self ) -> & ' a T {
123
+ impl < T : Const +Owned > ARC < T > {
124
+ pub fn get < ' a > ( & ' a self ) -> & ' a T {
125
125
unsafe { & * self . x . get_immut ( ) }
126
126
}
127
127
}
@@ -173,7 +173,7 @@ impl<T:Owned> Clone for MutexARC<T> {
173
173
}
174
174
}
175
175
176
- pub impl < T : Owned > MutexARC < T > {
176
+ impl < T : Owned > MutexARC < T > {
177
177
178
178
/**
179
179
* Access the underlying mutable data with mutual exclusion from other
@@ -199,7 +199,7 @@ pub impl<T:Owned> MutexARC<T> {
199
199
* blocked on the mutex) will also fail immediately.
200
200
*/
201
201
#[ inline( always) ]
202
- unsafe fn access < U > ( & self , blk : & fn ( x : & mut T ) -> U ) -> U {
202
+ pub unsafe fn access < U > ( & self , blk : & fn ( x : & mut T ) -> U ) -> U {
203
203
unsafe {
204
204
let state = self . x . get ( ) ;
205
205
// Borrowck would complain about this if the function were
@@ -214,10 +214,10 @@ pub impl<T:Owned> MutexARC<T> {
214
214
215
215
/// As access(), but with a condvar, as sync::mutex.lock_cond().
216
216
#[ inline( always) ]
217
- unsafe fn access_cond < ' x , ' c , U > (
218
- & self ,
219
- blk : & fn ( x : & ' x mut T , c : & ' c Condvar ) -> U ) -> U
220
- {
217
+ pub unsafe fn access_cond < ' x , ' c , U > ( & self ,
218
+ blk : & fn ( x : & ' x mut T ,
219
+ c : & ' c Condvar ) -> U )
220
+ -> U {
221
221
let state = self . x . get ( ) ;
222
222
do ( & ( * state) . lock ) . lock_cond |cond| {
223
223
check_poison ( true , ( * state) . failed ) ;
@@ -302,16 +302,18 @@ pub fn rw_arc_with_condvars<T:Const + Owned>(
302
302
RWARC { x : UnsafeAtomicRcBox :: new ( data) , cant_nest : ( ) }
303
303
}
304
304
305
- pub impl < T : Const + Owned > RWARC < T > {
305
+ impl < T : Const + Owned > RWARC < T > {
306
306
/// Duplicate a rwlock-protected ARC, as arc::clone.
307
- fn clone ( & self ) -> RWARC < T > {
308
- RWARC { x : self . x . clone ( ) ,
309
- cant_nest : ( ) }
307
+ pub fn clone ( & self ) -> RWARC < T > {
308
+ RWARC {
309
+ x : self . x . clone ( ) ,
310
+ cant_nest : ( ) ,
311
+ }
310
312
}
311
313
312
314
}
313
315
314
- pub impl < T : Const + Owned > RWARC < T > {
316
+ impl < T : Const + Owned > RWARC < T > {
315
317
/**
316
318
* Access the underlying data mutably. Locks the rwlock in write mode;
317
319
* other readers and writers will block.
@@ -323,7 +325,7 @@ pub impl<T:Const + Owned> RWARC<T> {
323
325
* poison the ARC, so subsequent readers and writers will both also fail.
324
326
*/
325
327
#[ inline( always) ]
326
- fn write < U > ( & self , blk : & fn ( x : & mut T ) -> U ) -> U {
328
+ pub fn write < U > ( & self , blk : & fn ( x : & mut T ) -> U ) -> U {
327
329
unsafe {
328
330
let state = self . x . get ( ) ;
329
331
do ( * borrow_rwlock ( state) ) . write {
@@ -333,11 +335,12 @@ pub impl<T:Const + Owned> RWARC<T> {
333
335
}
334
336
}
335
337
}
338
+
336
339
/// As write(), but with a condvar, as sync::rwlock.write_cond().
337
340
#[ inline( always) ]
338
- fn write_cond < ' x , ' c , U > ( & self ,
339
- blk : & fn ( x : & ' x mut T , c : & ' c Condvar ) -> U )
340
- -> U {
341
+ pub fn write_cond < ' x , ' c , U > ( & self ,
342
+ blk : & fn ( x : & ' x mut T , c : & ' c Condvar ) -> U )
343
+ -> U {
341
344
unsafe {
342
345
let state = self . x . get ( ) ;
343
346
do ( * borrow_rwlock ( state) ) . write_cond |cond| {
@@ -350,6 +353,7 @@ pub impl<T:Const + Owned> RWARC<T> {
350
353
}
351
354
}
352
355
}
356
+
353
357
/**
354
358
* Access the underlying data immutably. May run concurrently with other
355
359
* reading tasks.
@@ -359,7 +363,7 @@ pub impl<T:Const + Owned> RWARC<T> {
359
363
* Failing will unlock the ARC while unwinding. However, unlike all other
360
364
* access modes, this will not poison the ARC.
361
365
*/
362
- fn read < U > ( & self , blk : & fn ( x : & T ) -> U ) -> U {
366
+ pub fn read < U > ( & self , blk : & fn ( x : & T ) -> U ) -> U {
363
367
unsafe {
364
368
let state = self . x . get ( ) ;
365
369
do ( * state) . lock . read {
@@ -389,7 +393,7 @@ pub impl<T:Const + Owned> RWARC<T> {
389
393
* }
390
394
* ~~~
391
395
*/
392
- fn write_downgrade < U > ( & self , blk : & fn ( v : RWWriteMode < T > ) -> U ) -> U {
396
+ pub fn write_downgrade < U > ( & self , blk : & fn ( v : RWWriteMode < T > ) -> U ) -> U {
393
397
unsafe {
394
398
let state = self . x . get ( ) ;
395
399
do ( * borrow_rwlock ( state) ) . write_downgrade |write_mode| {
@@ -404,7 +408,8 @@ pub impl<T:Const + Owned> RWARC<T> {
404
408
}
405
409
406
410
/// To be called inside of the write_downgrade block.
407
- fn downgrade < ' a > ( & self , token : RWWriteMode < ' a , T > ) -> RWReadMode < ' a , T > {
411
+ pub fn downgrade < ' a > ( & self , token : RWWriteMode < ' a , T > )
412
+ -> RWReadMode < ' a , T > {
408
413
unsafe {
409
414
// The rwlock should assert that the token belongs to us for us.
410
415
let state = self . x . get ( ) ;
@@ -451,9 +456,9 @@ pub struct RWReadMode<'self, T> {
451
456
token : sync:: RWlockReadMode < ' self > ,
452
457
}
453
458
454
- pub impl < ' self , T : Const + Owned > RWWriteMode < ' self , T > {
459
+ impl < ' self , T : Const + Owned > RWWriteMode < ' self , T > {
455
460
/// Access the pre-downgrade RWARC in write mode.
456
- fn write < U > ( & mut self , blk : & fn ( x : & mut T ) -> U ) -> U {
461
+ pub fn write < U > ( & mut self , blk : & fn ( x : & mut T ) -> U ) -> U {
457
462
match * self {
458
463
RWWriteMode {
459
464
data : & ref mut data,
@@ -466,10 +471,11 @@ pub impl<'self, T:Const + Owned> RWWriteMode<'self, T> {
466
471
}
467
472
}
468
473
}
474
+
469
475
/// Access the pre-downgrade RWARC in write mode with a condvar.
470
- fn write_cond < ' x , ' c , U > ( & mut self ,
471
- blk : & fn ( x : & ' x mut T , c : & ' c Condvar ) -> U )
472
- -> U {
476
+ pub fn write_cond < ' x , ' c , U > ( & mut self ,
477
+ blk : & fn ( x : & ' x mut T , c : & ' c Condvar ) -> U )
478
+ -> U {
473
479
match * self {
474
480
RWWriteMode {
475
481
data : & ref mut data,
@@ -491,9 +497,9 @@ pub impl<'self, T:Const + Owned> RWWriteMode<'self, T> {
491
497
}
492
498
}
493
499
494
- pub impl < ' self , T : Const + Owned > RWReadMode < ' self , T > {
500
+ impl < ' self , T : Const + Owned > RWReadMode < ' self , T > {
495
501
/// Access the post-downgrade rwlock in read mode.
496
- fn read < U > ( & self , blk : & fn ( x : & T ) -> U ) -> U {
502
+ pub fn read < U > ( & self , blk : & fn ( x : & T ) -> U ) -> U {
497
503
match * self {
498
504
RWReadMode {
499
505
data : data,
0 commit comments