Skip to content

Commit a49ce7f

Browse files
committed
sync: Switch field privacy as necessary
1 parent 02cf375 commit a49ce7f

File tree

10 files changed

+61
-57
lines changed

10 files changed

+61
-57
lines changed

src/libsync/arc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use std::sync::atomics;
4646
/// ```
4747
#[unsafe_no_drop_flag]
4848
pub struct Arc<T> {
49-
priv x: *mut ArcInner<T>,
49+
x: *mut ArcInner<T>,
5050
}
5151

5252
/// A weak pointer to an `Arc`.
@@ -55,7 +55,7 @@ pub struct Arc<T> {
5555
/// used to break cycles between `Arc` pointers.
5656
#[unsafe_no_drop_flag]
5757
pub struct Weak<T> {
58-
priv x: *mut ArcInner<T>,
58+
x: *mut ArcInner<T>,
5959
}
6060

6161
struct ArcInner<T> {

src/libsync/comm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use std::comm;
2020

2121
/// An extension of `pipes::stream` that allows both sending and receiving.
2222
pub struct DuplexStream<S, R> {
23-
priv tx: Sender<S>,
24-
priv rx: Receiver<R>,
23+
tx: Sender<S>,
24+
rx: Receiver<R>,
2525
}
2626

2727
/// Creates a bidirectional stream.

src/libsync/future.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use std::mem::replace;
3030

3131
/// A type encapsulating the result of a computation which may not be complete
3232
pub struct Future<A> {
33-
priv state: FutureState<A>,
33+
state: FutureState<A>,
3434
}
3535

3636
enum FutureState<A> {

src/libsync/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2121
html_root_url = "http://static.rust-lang.org/doc/master")]
2222
#![feature(phase)]
23-
#![deny(missing_doc, deprecated_owned_vector)]
23+
#![deny(deprecated_owned_vector)]
24+
25+
// #![deny(missing_doc)] // NOTE: uncomment after a stage0 snap
26+
#![allow(missing_doc)] // NOTE: remove after a stage0 snap
27+
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
2428

2529
#[cfg(test)]
2630
#[phase(syntax, link)] extern crate log;

src/libsync/lock.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ impl<'b> Inner<'b> {
7979
/// A condition variable, a mechanism for unlock-and-descheduling and
8080
/// signaling, for use with the lock types.
8181
pub struct Condvar<'a> {
82-
priv name: &'static str,
82+
name: &'static str,
8383
// n.b. Inner must be after PoisonOnFail because we must set the poison flag
8484
// *inside* the mutex, and struct fields are destroyed top-to-bottom
8585
// (destroy the lock guard last).
86-
priv poison: PoisonOnFail<'a>,
87-
priv inner: Inner<'a>,
86+
poison: PoisonOnFail<'a>,
87+
inner: Inner<'a>,
8888
}
8989

9090
impl<'a> Condvar<'a> {
@@ -166,18 +166,18 @@ impl<'a> Condvar<'a> {
166166
/// }
167167
/// ```
168168
pub struct Mutex<T> {
169-
priv lock: raw::Mutex,
170-
priv failed: Unsafe<bool>,
171-
priv data: Unsafe<T>,
169+
lock: raw::Mutex,
170+
failed: Unsafe<bool>,
171+
data: Unsafe<T>,
172172
}
173173

174174
/// An guard which is created by locking a mutex. Through this guard the
175175
/// underlying data can be accessed.
176176
pub struct MutexGuard<'a, T> {
177-
priv data: &'a mut T,
177+
data: &'a mut T,
178178
/// Inner condition variable connected to the locked mutex that this guard
179179
/// was created from. This can be used for atomic-unlock-and-deschedule.
180-
cond: Condvar<'a>,
180+
pub cond: Condvar<'a>,
181181
}
182182

183183
impl<T: Send> Mutex<T> {
@@ -265,25 +265,25 @@ impl<'a, T> DerefMut<T> for MutexGuard<'a, T> {
265265
/// println!("{}", *val);
266266
/// ```
267267
pub struct RWLock<T> {
268-
priv lock: raw::RWLock,
269-
priv failed: Unsafe<bool>,
270-
priv data: Unsafe<T>,
268+
lock: raw::RWLock,
269+
failed: Unsafe<bool>,
270+
data: Unsafe<T>,
271271
}
272272

273273
/// A guard which is created by locking an rwlock in write mode. Through this
274274
/// guard the underlying data can be accessed.
275275
pub struct RWLockWriteGuard<'a, T> {
276-
priv data: &'a mut T,
276+
data: &'a mut T,
277277
/// Inner condition variable that can be used to sleep on the write mode of
278278
/// this rwlock.
279-
cond: Condvar<'a>,
279+
pub cond: Condvar<'a>,
280280
}
281281

282282
/// A guard which is created by locking an rwlock in read mode. Through this
283283
/// guard the underlying data can be accessed.
284284
pub struct RWLockReadGuard<'a, T> {
285-
priv data: &'a T,
286-
priv guard: raw::RWLockReadGuard<'a>,
285+
data: &'a T,
286+
guard: raw::RWLockReadGuard<'a>,
287287
}
288288

289289
impl<T: Send + Share> RWLock<T> {
@@ -397,8 +397,8 @@ impl<'a, T> DerefMut<T> for RWLockWriteGuard<'a, T> {
397397
/// }
398398
/// ```
399399
pub struct Barrier {
400-
priv lock: Mutex<BarrierState>,
401-
priv num_tasks: uint,
400+
lock: Mutex<BarrierState>,
401+
num_tasks: uint,
402402
}
403403

404404
// The inner state of a double barrier

src/libsync/mpsc_intrusive.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ use std::ty::Unsafe;
4141
// initialization.
4242

4343
pub struct Node<T> {
44-
next: atomics::AtomicUint,
45-
data: T,
44+
pub next: atomics::AtomicUint,
45+
pub data: T,
4646
}
4747

4848
pub struct DummyNode {
49-
next: atomics::AtomicUint,
49+
pub next: atomics::AtomicUint,
5050
}
5151

5252
pub struct Queue<T> {
53-
head: atomics::AtomicUint,
54-
tail: Unsafe<*mut Node<T>>,
55-
stub: DummyNode,
53+
pub head: atomics::AtomicUint,
54+
pub tail: Unsafe<*mut Node<T>>,
55+
pub stub: DummyNode,
5656
}
5757

5858
impl<T: Send> Queue<T> {

src/libsync/mutex.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub static NATIVE_BLOCKED: uint = 1 << 2;
9494
/// drop(guard); // unlock the lock
9595
/// ```
9696
pub struct Mutex {
97-
priv lock: StaticMutex,
97+
lock: StaticMutex,
9898
}
9999

100100
#[deriving(Eq, Show)]
@@ -128,28 +128,28 @@ enum Flavor {
128128
/// ```
129129
pub struct StaticMutex {
130130
/// Current set of flags on this mutex
131-
priv state: atomics::AtomicUint,
131+
state: atomics::AtomicUint,
132132
/// an OS mutex used by native threads
133-
priv lock: mutex::StaticNativeMutex,
133+
lock: mutex::StaticNativeMutex,
134134

135135
/// Type of locking operation currently on this mutex
136-
priv flavor: Unsafe<Flavor>,
136+
flavor: Unsafe<Flavor>,
137137
/// uint-cast of the green thread waiting for this mutex
138-
priv green_blocker: Unsafe<uint>,
138+
green_blocker: Unsafe<uint>,
139139
/// uint-cast of the native thread waiting for this mutex
140-
priv native_blocker: Unsafe<uint>,
140+
native_blocker: Unsafe<uint>,
141141

142142
/// A concurrent mpsc queue used by green threads, along with a count used
143143
/// to figure out when to dequeue and enqueue.
144-
priv q: q::Queue<uint>,
145-
priv green_cnt: atomics::AtomicUint,
144+
q: q::Queue<uint>,
145+
green_cnt: atomics::AtomicUint,
146146
}
147147

148148
/// An RAII implementation of a "scoped lock" of a mutex. When this structure is
149149
/// dropped (falls out of scope), the lock will be unlocked.
150150
#[must_use]
151151
pub struct Guard<'a> {
152-
priv lock: &'a StaticMutex,
152+
lock: &'a StaticMutex,
153153
}
154154

155155
/// Static initialization of a mutex. This constant can be used to initialize

src/libsync/one.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ use mutex::{StaticMutex, MUTEX_INIT};
4141
/// }
4242
/// ```
4343
pub struct Once {
44-
priv mutex: StaticMutex,
45-
priv cnt: atomics::AtomicInt,
46-
priv lock_cnt: atomics::AtomicInt,
44+
mutex: StaticMutex,
45+
cnt: atomics::AtomicInt,
46+
lock_cnt: atomics::AtomicInt,
4747
}
4848

4949
/// Initialization value for static `Once` values.

src/libsync/raw.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,16 @@ enum ReacquireOrderLock<'a> {
209209
pub struct Condvar<'a> {
210210
// The 'Sem' object associated with this condvar. This is the one that's
211211
// atomically-unlocked-and-descheduled upon and reacquired during wakeup.
212-
priv sem: &'a Sem<Vec<WaitQueue> >,
212+
sem: &'a Sem<Vec<WaitQueue> >,
213213
// This is (can be) an extra semaphore which is held around the reacquire
214214
// operation on the first one. This is only used in cvars associated with
215215
// rwlocks, and is needed to ensure that, when a downgrader is trying to
216216
// hand off the access lock (which would be the first field, here), a 2nd
217217
// writer waking up from a cvar wait can't race with a reader to steal it,
218218
// See the comment in write_cond for more detail.
219-
priv order: ReacquireOrderLock<'a>,
219+
order: ReacquireOrderLock<'a>,
220220
// Make sure condvars are non-copyable.
221-
priv nocopy: marker::NoCopy,
221+
nocopy: marker::NoCopy,
222222
}
223223

224224
impl<'a> Condvar<'a> {
@@ -362,14 +362,14 @@ struct SemCondGuard<'a> {
362362

363363
/// A counting, blocking, bounded-waiting semaphore.
364364
pub struct Semaphore {
365-
priv sem: Sem<()>,
365+
sem: Sem<()>,
366366
}
367367

368368
/// An RAII guard used to represent an acquired resource to a semaphore. When
369369
/// dropped, this value will release the resource back to the semaphore.
370370
#[must_use]
371371
pub struct SemaphoreGuard<'a> {
372-
priv guard: SemGuard<'a, ()>,
372+
guard: SemGuard<'a, ()>,
373373
}
374374

375375
impl Semaphore {
@@ -404,18 +404,18 @@ impl Semaphore {
404404
/// A task which fails while holding a mutex will unlock the mutex as it
405405
/// unwinds.
406406
pub struct Mutex {
407-
priv sem: Sem<Vec<WaitQueue>>,
407+
sem: Sem<Vec<WaitQueue>>,
408408
}
409409

410410
/// An RAII structure which is used to gain access to a mutex's condition
411411
/// variable. Additionally, when a value of this type is dropped, the
412412
/// corresponding mutex is also unlocked.
413413
#[must_use]
414414
pub struct MutexGuard<'a> {
415-
priv guard: SemGuard<'a, Vec<WaitQueue>>,
415+
guard: SemGuard<'a, Vec<WaitQueue>>,
416416
/// Inner condition variable which is connected to the outer mutex, and can
417417
/// be used for atomic-unlock-and-deschedule.
418-
cond: Condvar<'a>,
418+
pub cond: Condvar<'a>,
419419
}
420420

421421
impl Mutex {
@@ -452,8 +452,8 @@ impl Mutex {
452452
/// A task which fails while holding an rwlock will unlock the rwlock as it
453453
/// unwinds.
454454
pub struct RWLock {
455-
priv order_lock: Semaphore,
456-
priv access_lock: Sem<Vec<WaitQueue>>,
455+
order_lock: Semaphore,
456+
access_lock: Sem<Vec<WaitQueue>>,
457457

458458
// The only way the count flag is ever accessed is with xadd. Since it is
459459
// a read-modify-write operation, multiple xadds on different cores will
@@ -462,14 +462,14 @@ pub struct RWLock {
462462
//
463463
// FIXME(#6598): The atomics module has no relaxed ordering flag, so I use
464464
// acquire/release orderings superfluously. Change these someday.
465-
priv read_count: atomics::AtomicUint,
465+
read_count: atomics::AtomicUint,
466466
}
467467

468468
/// An RAII helper which is created by acquiring a read lock on an RWLock. When
469469
/// dropped, this will unlock the RWLock.
470470
#[must_use]
471471
pub struct RWLockReadGuard<'a> {
472-
priv lock: &'a RWLock,
472+
lock: &'a RWLock,
473473
}
474474

475475
/// An RAII helper which is created by acquiring a write lock on an RWLock. When
@@ -478,10 +478,10 @@ pub struct RWLockReadGuard<'a> {
478478
/// A value of this type can also be consumed to downgrade to a read-only lock.
479479
#[must_use]
480480
pub struct RWLockWriteGuard<'a> {
481-
priv lock: &'a RWLock,
481+
lock: &'a RWLock,
482482
/// Inner condition variable that is connected to the write-mode of the
483483
/// outer rwlock.
484-
cond: Condvar<'a>,
484+
pub cond: Condvar<'a>,
485485
}
486486

487487
impl RWLock {

src/libsync/task_pool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ enum Msg<T> {
2121
}
2222

2323
pub struct TaskPool<T> {
24-
priv channels: Vec<Sender<Msg<T>>>,
25-
priv next_index: uint,
24+
channels: Vec<Sender<Msg<T>>>,
25+
next_index: uint,
2626
}
2727

2828
#[unsafe_destructor]

0 commit comments

Comments
 (0)