@@ -31,17 +31,17 @@ use sys_common::rwlock as sys;
31
31
///
32
32
/// # Poisoning
33
33
///
34
- /// RWLocks , like Mutexes, will become poisoned on panics. Note, however, that
35
- /// an RWLock may only be poisoned if a panic occurs while it is locked
34
+ /// RwLocks , like Mutexes, will become poisoned on panics. Note, however, that
35
+ /// an RwLock may only be poisoned if a panic occurs while it is locked
36
36
/// exclusively (write mode). If a panic occurs in any reader, then the lock
37
37
/// will not be poisoned.
38
38
///
39
39
/// # Examples
40
40
///
41
41
/// ```
42
- /// use std::sync::RWLock ;
42
+ /// use std::sync::RwLock ;
43
43
///
44
- /// let lock = RWLock ::new(5i);
44
+ /// let lock = RwLock ::new(5i);
45
45
///
46
46
/// // many reader locks can be held at once
47
47
/// {
@@ -67,11 +67,11 @@ pub struct RwLock<T> {
67
67
unsafe impl < T : ' static +Send > Send for RwLock < T > { }
68
68
unsafe impl < T > Sync for RwLock < T > { }
69
69
70
- /// Structure representing a statically allocated RWLock .
70
+ /// Structure representing a statically allocated RwLock .
71
71
///
72
72
/// This structure is intended to be used inside of a `static` and will provide
73
73
/// automatic global access as well as lazy initialization. The internal
74
- /// resources of this RWLock , however, must be manually deallocated.
74
+ /// resources of this RwLock , however, must be manually deallocated.
75
75
///
76
76
/// # Example
77
77
///
@@ -90,7 +90,7 @@ unsafe impl<T> Sync for RwLock<T> {}
90
90
/// }
91
91
/// unsafe { LOCK.destroy() } // free all resources
92
92
/// ```
93
- #[ unstable = "may be merged with RWLock in the future" ]
93
+ #[ unstable = "may be merged with RwLock in the future" ]
94
94
pub struct StaticRWLock {
95
95
lock : sys:: RWLock ,
96
96
poison : poison:: Flag ,
@@ -100,7 +100,7 @@ unsafe impl Send for StaticRWLock {}
100
100
unsafe impl Sync for StaticRWLock { }
101
101
102
102
/// Constant initialization for a statically-initialized rwlock.
103
- #[ unstable = "may be merged with RWLock in the future" ]
103
+ #[ unstable = "may be merged with RwLock in the future" ]
104
104
pub const RWLOCK_INIT : StaticRWLock = StaticRWLock {
105
105
lock : sys:: RWLOCK_INIT ,
106
106
poison : poison:: FLAG_INIT ,
@@ -128,7 +128,7 @@ pub struct RWLockWriteGuard<'a, T: 'a> {
128
128
}
129
129
130
130
impl < T : Send + Sync > RwLock < T > {
131
- /// Creates a new instance of an RWLock which is unlocked and read to go.
131
+ /// Creates a new instance of an RwLock which is unlocked and read to go.
132
132
#[ stable]
133
133
pub fn new ( t : T ) -> RwLock < T > {
134
134
RwLock { inner : box RWLOCK_INIT , data : UnsafeCell :: new ( t) }
@@ -148,7 +148,7 @@ impl<T: Send + Sync> RwLock<T> {
148
148
///
149
149
/// # Failure
150
150
///
151
- /// This function will return an error if the RWLock is poisoned. An RWLock
151
+ /// This function will return an error if the RwLock is poisoned. An RwLock
152
152
/// is poisoned whenever a writer panics while holding an exclusive lock.
153
153
/// The failure will occur immediately after the lock has been acquired.
154
154
#[ inline]
@@ -169,7 +169,7 @@ impl<T: Send + Sync> RwLock<T> {
169
169
///
170
170
/// # Failure
171
171
///
172
- /// This function will return an error if the RWLock is poisoned. An RWLock
172
+ /// This function will return an error if the RwLock is poisoned. An RwLock
173
173
/// is poisoned whenever a writer panics while holding an exclusive lock. An
174
174
/// error will only be returned if the lock would have otherwise been
175
175
/// acquired.
@@ -194,7 +194,7 @@ impl<T: Send + Sync> RwLock<T> {
194
194
///
195
195
/// # Failure
196
196
///
197
- /// This function will return an error if the RWLock is poisoned. An RWLock
197
+ /// This function will return an error if the RwLock is poisoned. An RwLock
198
198
/// is poisoned whenever a writer panics while holding an exclusive lock.
199
199
/// An error will be returned when the lock is acquired.
200
200
#[ inline]
@@ -212,7 +212,7 @@ impl<T: Send + Sync> RwLock<T> {
212
212
///
213
213
/// # Failure
214
214
///
215
- /// This function will return an error if the RWLock is poisoned. An RWLock
215
+ /// This function will return an error if the RwLock is poisoned. An RwLock
216
216
/// is poisoned whenever a writer panics while holding an exclusive lock. An
217
217
/// error will only be returned if the lock would have otherwise been
218
218
/// acquired.
@@ -242,19 +242,19 @@ impl StaticRWLock {
242
242
/// Locks this rwlock with shared read access, blocking the current thread
243
243
/// until it can be acquired.
244
244
///
245
- /// See `RWLock ::read`.
245
+ /// See `RwLock ::read`.
246
246
#[ inline]
247
- #[ unstable = "may be merged with RWLock in the future" ]
247
+ #[ unstable = "may be merged with RwLock in the future" ]
248
248
pub fn read ( & ' static self ) -> LockResult < RWLockReadGuard < ' static , ( ) > > {
249
249
unsafe { self . lock . read ( ) }
250
250
RWLockReadGuard :: new ( self , & DUMMY . 0 )
251
251
}
252
252
253
253
/// Attempt to acquire this lock with shared read access.
254
254
///
255
- /// See `RWLock ::try_read`.
255
+ /// See `RwLock ::try_read`.
256
256
#[ inline]
257
- #[ unstable = "may be merged with RWLock in the future" ]
257
+ #[ unstable = "may be merged with RwLock in the future" ]
258
258
pub fn try_read ( & ' static self )
259
259
-> TryLockResult < RWLockReadGuard < ' static , ( ) > > {
260
260
if unsafe { self . lock . try_read ( ) } {
@@ -267,19 +267,19 @@ impl StaticRWLock {
267
267
/// Lock this rwlock with exclusive write access, blocking the current
268
268
/// thread until it can be acquired.
269
269
///
270
- /// See `RWLock ::write`.
270
+ /// See `RwLock ::write`.
271
271
#[ inline]
272
- #[ unstable = "may be merged with RWLock in the future" ]
272
+ #[ unstable = "may be merged with RwLock in the future" ]
273
273
pub fn write ( & ' static self ) -> LockResult < RWLockWriteGuard < ' static , ( ) > > {
274
274
unsafe { self . lock . write ( ) }
275
275
RWLockWriteGuard :: new ( self , & DUMMY . 0 )
276
276
}
277
277
278
278
/// Attempt to lock this rwlock with exclusive write access.
279
279
///
280
- /// See `RWLock ::try_write`.
280
+ /// See `RwLock ::try_write`.
281
281
#[ inline]
282
- #[ unstable = "may be merged with RWLock in the future" ]
282
+ #[ unstable = "may be merged with RwLock in the future" ]
283
283
pub fn try_write ( & ' static self )
284
284
-> TryLockResult < RWLockWriteGuard < ' static , ( ) > > {
285
285
if unsafe { self . lock . try_write ( ) } {
@@ -295,7 +295,7 @@ impl StaticRWLock {
295
295
/// active users of the lock, and this also doesn't prevent any future users
296
296
/// of this lock. This method is required to be called to not leak memory on
297
297
/// all platforms.
298
- #[ unstable = "may be merged with RWLock in the future" ]
298
+ #[ unstable = "may be merged with RwLock in the future" ]
299
299
pub unsafe fn destroy ( & ' static self ) {
300
300
self . lock . destroy ( )
301
301
}
@@ -365,11 +365,11 @@ mod tests {
365
365
use rand:: { mod, Rng } ;
366
366
use sync:: mpsc:: channel;
367
367
use thread:: Thread ;
368
- use sync:: { Arc , RWLock , StaticRWLock , RWLOCK_INIT } ;
368
+ use sync:: { Arc , RwLock , StaticRWLock , RWLOCK_INIT } ;
369
369
370
370
#[ test]
371
371
fn smoke ( ) {
372
- let l = RWLock :: new ( ( ) ) ;
372
+ let l = RwLock :: new ( ( ) ) ;
373
373
drop ( l. read ( ) . unwrap ( ) ) ;
374
374
drop ( l. write ( ) . unwrap ( ) ) ;
375
375
drop ( ( l. read ( ) . unwrap ( ) , l. read ( ) . unwrap ( ) ) ) ;
@@ -414,7 +414,7 @@ mod tests {
414
414
415
415
#[ test]
416
416
fn test_rw_arc_poison_wr ( ) {
417
- let arc = Arc :: new ( RWLock :: new ( 1 i) ) ;
417
+ let arc = Arc :: new ( RwLock :: new ( 1 i) ) ;
418
418
let arc2 = arc. clone ( ) ;
419
419
let _: Result < uint , _ > = Thread :: spawn ( move || {
420
420
let _lock = arc2. write ( ) . unwrap ( ) ;
@@ -425,7 +425,7 @@ mod tests {
425
425
426
426
#[ test]
427
427
fn test_rw_arc_poison_ww ( ) {
428
- let arc = Arc :: new ( RWLock :: new ( 1 i) ) ;
428
+ let arc = Arc :: new ( RwLock :: new ( 1 i) ) ;
429
429
let arc2 = arc. clone ( ) ;
430
430
let _: Result < uint , _ > = Thread :: spawn ( move || {
431
431
let _lock = arc2. write ( ) . unwrap ( ) ;
@@ -436,7 +436,7 @@ mod tests {
436
436
437
437
#[ test]
438
438
fn test_rw_arc_no_poison_rr ( ) {
439
- let arc = Arc :: new ( RWLock :: new ( 1 i) ) ;
439
+ let arc = Arc :: new ( RwLock :: new ( 1 i) ) ;
440
440
let arc2 = arc. clone ( ) ;
441
441
let _: Result < uint , _ > = Thread :: spawn ( move || {
442
442
let _lock = arc2. read ( ) . unwrap ( ) ;
@@ -447,7 +447,7 @@ mod tests {
447
447
}
448
448
#[ test]
449
449
fn test_rw_arc_no_poison_rw ( ) {
450
- let arc = Arc :: new ( RWLock :: new ( 1 i) ) ;
450
+ let arc = Arc :: new ( RwLock :: new ( 1 i) ) ;
451
451
let arc2 = arc. clone ( ) ;
452
452
let _: Result < uint , _ > = Thread :: spawn ( move || {
453
453
let _lock = arc2. read ( ) . unwrap ( ) ;
@@ -459,7 +459,7 @@ mod tests {
459
459
460
460
#[ test]
461
461
fn test_rw_arc ( ) {
462
- let arc = Arc :: new ( RWLock :: new ( 0 i) ) ;
462
+ let arc = Arc :: new ( RwLock :: new ( 0 i) ) ;
463
463
let arc2 = arc. clone ( ) ;
464
464
let ( tx, rx) = channel ( ) ;
465
465
@@ -497,11 +497,11 @@ mod tests {
497
497
498
498
#[ test]
499
499
fn test_rw_arc_access_in_unwind ( ) {
500
- let arc = Arc :: new ( RWLock :: new ( 1 i) ) ;
500
+ let arc = Arc :: new ( RwLock :: new ( 1 i) ) ;
501
501
let arc2 = arc. clone ( ) ;
502
502
let _ = Thread :: spawn ( move || -> ( ) {
503
503
struct Unwinder {
504
- i : Arc < RWLock < int > > ,
504
+ i : Arc < RwLock < int > > ,
505
505
}
506
506
impl Drop for Unwinder {
507
507
fn drop ( & mut self ) {
0 commit comments