@@ -56,10 +56,10 @@ pub struct Condvar<'self> {
56
56
cond : & ' self sync:: Condvar < ' self >
57
57
}
58
58
59
- impl < ' self > Condvar < ' self > {
59
+ pub impl < ' self > Condvar < ' self > {
60
60
/// Atomically exit the associated ARC and block until a signal is sent.
61
61
#[ inline( always) ]
62
- pub fn wait ( & self ) { self . wait_on ( 0 ) }
62
+ 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 @@ impl<'self> Condvar<'self> {
68
68
* wait() is equivalent to wait_on(0).
69
69
*/
70
70
#[ inline( always) ]
71
- pub fn wait_on ( & self , condvar_id : uint ) {
71
+ 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 @@ 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
- pub fn signal ( & self ) -> bool { self . signal_on ( 0 ) }
80
+ 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
- pub fn signal_on ( & self , condvar_id : uint ) -> bool {
87
+ 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
- pub fn broadcast ( & self ) -> uint { self . broadcast_on ( 0 ) }
94
+ 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
- pub fn broadcast_on ( & self , condvar_id : uint ) -> uint {
101
+ 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
- impl < T : Const +Owned > ARC < T > {
124
- pub fn get < ' a > ( & ' a self ) -> & ' a T {
123
+ pub impl < T : Const +Owned > ARC < T > {
124
+ 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
- impl < T : Owned > MutexARC < T > {
176
+ pub 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 @@ impl<T:Owned> MutexARC<T> {
199
199
* blocked on the mutex) will also fail immediately.
200
200
*/
201
201
#[ inline( always) ]
202
- pub unsafe fn access < U > ( & self , blk : & fn ( x : & mut T ) -> U ) -> U {
202
+ 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 @@ 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
- pub unsafe fn access_cond < ' x , ' c , U > ( & self ,
218
- blk : & fn ( x : & ' x mut T ,
219
- c : & ' c Condvar ) -> U )
220
- -> U {
217
+ unsafe fn access_cond < ' x , ' c , U > (
218
+ & self ,
219
+ blk : & fn ( x : & ' x mut T , c : & ' c Condvar ) -> U ) -> U
220
+ {
221
221
let state = self . x . get ( ) ;
222
222
do ( & ( * state) . lock ) . lock_cond |cond| {
223
223
check_poison ( true , ( * state) . failed ) ;
@@ -302,18 +302,16 @@ pub fn rw_arc_with_condvars<T:Const + Owned>(
302
302
RWARC { x : UnsafeAtomicRcBox :: new ( data) , cant_nest : ( ) }
303
303
}
304
304
305
- impl < T : Const + Owned > RWARC < T > {
305
+ pub impl < T : Const + Owned > RWARC < T > {
306
306
/// Duplicate a rwlock-protected ARC, as arc::clone.
307
- pub fn clone ( & self ) -> RWARC < T > {
308
- RWARC {
309
- x : self . x . clone ( ) ,
310
- cant_nest : ( ) ,
311
- }
307
+ fn clone ( & self ) -> RWARC < T > {
308
+ RWARC { x : self . x . clone ( ) ,
309
+ cant_nest : ( ) }
312
310
}
313
311
314
312
}
315
313
316
- impl < T : Const + Owned > RWARC < T > {
314
+ pub impl < T : Const + Owned > RWARC < T > {
317
315
/**
318
316
* Access the underlying data mutably. Locks the rwlock in write mode;
319
317
* other readers and writers will block.
@@ -325,7 +323,7 @@ impl<T:Const + Owned> RWARC<T> {
325
323
* poison the ARC, so subsequent readers and writers will both also fail.
326
324
*/
327
325
#[ inline( always) ]
328
- pub fn write < U > ( & self , blk : & fn ( x : & mut T ) -> U ) -> U {
326
+ fn write < U > ( & self , blk : & fn ( x : & mut T ) -> U ) -> U {
329
327
unsafe {
330
328
let state = self . x . get ( ) ;
331
329
do ( * borrow_rwlock ( state) ) . write {
@@ -335,12 +333,11 @@ impl<T:Const + Owned> RWARC<T> {
335
333
}
336
334
}
337
335
}
338
-
339
336
/// As write(), but with a condvar, as sync::rwlock.write_cond().
340
337
#[ inline( always) ]
341
- pub fn write_cond < ' x , ' c , U > ( & self ,
342
- blk : & fn ( x : & ' x mut T , c : & ' c Condvar ) -> U )
343
- -> U {
338
+ fn write_cond < ' x , ' c , U > ( & self ,
339
+ blk : & fn ( x : & ' x mut T , c : & ' c Condvar ) -> U )
340
+ -> U {
344
341
unsafe {
345
342
let state = self . x . get ( ) ;
346
343
do ( * borrow_rwlock ( state) ) . write_cond |cond| {
@@ -353,7 +350,6 @@ impl<T:Const + Owned> RWARC<T> {
353
350
}
354
351
}
355
352
}
356
-
357
353
/**
358
354
* Access the underlying data immutably. May run concurrently with other
359
355
* reading tasks.
@@ -363,7 +359,7 @@ impl<T:Const + Owned> RWARC<T> {
363
359
* Failing will unlock the ARC while unwinding. However, unlike all other
364
360
* access modes, this will not poison the ARC.
365
361
*/
366
- pub fn read < U > ( & self , blk : & fn ( x : & T ) -> U ) -> U {
362
+ fn read < U > ( & self , blk : & fn ( x : & T ) -> U ) -> U {
367
363
unsafe {
368
364
let state = self . x . get ( ) ;
369
365
do ( * state) . lock . read {
@@ -393,7 +389,7 @@ impl<T:Const + Owned> RWARC<T> {
393
389
* }
394
390
* ~~~
395
391
*/
396
- pub fn write_downgrade < U > ( & self , blk : & fn ( v : RWWriteMode < T > ) -> U ) -> U {
392
+ fn write_downgrade < U > ( & self , blk : & fn ( v : RWWriteMode < T > ) -> U ) -> U {
397
393
unsafe {
398
394
let state = self . x . get ( ) ;
399
395
do ( * borrow_rwlock ( state) ) . write_downgrade |write_mode| {
@@ -408,8 +404,7 @@ impl<T:Const + Owned> RWARC<T> {
408
404
}
409
405
410
406
/// To be called inside of the write_downgrade block.
411
- pub fn downgrade < ' a > ( & self , token : RWWriteMode < ' a , T > )
412
- -> RWReadMode < ' a , T > {
407
+ fn downgrade < ' a > ( & self , token : RWWriteMode < ' a , T > ) -> RWReadMode < ' a , T > {
413
408
unsafe {
414
409
// The rwlock should assert that the token belongs to us for us.
415
410
let state = self . x . get ( ) ;
@@ -456,9 +451,9 @@ pub struct RWReadMode<'self, T> {
456
451
token : sync:: RWlockReadMode < ' self > ,
457
452
}
458
453
459
- impl < ' self , T : Const + Owned > RWWriteMode < ' self , T > {
454
+ pub impl < ' self , T : Const + Owned > RWWriteMode < ' self , T > {
460
455
/// Access the pre-downgrade RWARC in write mode.
461
- pub fn write < U > ( & mut self , blk : & fn ( x : & mut T ) -> U ) -> U {
456
+ fn write < U > ( & mut self , blk : & fn ( x : & mut T ) -> U ) -> U {
462
457
match * self {
463
458
RWWriteMode {
464
459
data : & ref mut data,
@@ -471,11 +466,10 @@ impl<'self, T:Const + Owned> RWWriteMode<'self, T> {
471
466
}
472
467
}
473
468
}
474
-
475
469
/// Access the pre-downgrade RWARC in write mode with a condvar.
476
- pub fn write_cond < ' x , ' c , U > ( & mut self ,
477
- blk : & fn ( x : & ' x mut T , c : & ' c Condvar ) -> U )
478
- -> U {
470
+ fn write_cond < ' x , ' c , U > ( & mut self ,
471
+ blk : & fn ( x : & ' x mut T , c : & ' c Condvar ) -> U )
472
+ -> U {
479
473
match * self {
480
474
RWWriteMode {
481
475
data : & ref mut data,
@@ -497,9 +491,9 @@ impl<'self, T:Const + Owned> RWWriteMode<'self, T> {
497
491
}
498
492
}
499
493
500
- impl < ' self , T : Const + Owned > RWReadMode < ' self , T > {
494
+ pub impl < ' self , T : Const + Owned > RWReadMode < ' self , T > {
501
495
/// Access the post-downgrade rwlock in read mode.
502
- pub fn read < U > ( & self , blk : & fn ( x : & T ) -> U ) -> U {
496
+ fn read < U > ( & self , blk : & fn ( x : & T ) -> U ) -> U {
503
497
match * self {
504
498
RWReadMode {
505
499
data : data,
0 commit comments