1
Fork 0

De-export std::{arc,comm,sync}. Part of #3583.

This commit is contained in:
Graydon Hoare 2012-09-28 16:05:33 -07:00
parent 4b7d4cd0cf
commit 43a9d90b48
4 changed files with 20 additions and 33 deletions

View file

@ -11,14 +11,9 @@ use private::{SharedMutableState, shared_mutable_state,
use sync::{Mutex, mutex_with_condvars, use sync::{Mutex, mutex_with_condvars,
RWlock, rwlock_with_condvars}; RWlock, rwlock_with_condvars};
export ARC, clone, get;
export Condvar;
export MutexARC, mutex_arc_with_condvars, unwrap_mutex_arc;
export RWARC, rw_arc_with_condvars, RWWriteMode, RWReadMode;
export unwrap_rw_arc;
/// As sync::condvar, a mechanism for unlock-and-descheduling and signalling. /// As sync::condvar, a mechanism for unlock-and-descheduling and signalling.
struct Condvar { is_mutex: bool, failed: &mut bool, cond: &sync::Condvar } pub struct Condvar { is_mutex: bool, failed: &mut bool, cond: &sync::Condvar }
impl &Condvar { impl &Condvar {
/// Atomically exit the associated ARC and block until a signal is sent. /// Atomically exit the associated ARC and block until a signal is sent.
@ -71,7 +66,7 @@ impl &Condvar {
struct ARC<T: Const Send> { x: SharedMutableState<T> } struct ARC<T: Const Send> { x: SharedMutableState<T> }
/// Create an atomically reference counted wrapper. /// Create an atomically reference counted wrapper.
fn ARC<T: Const Send>(+data: T) -> ARC<T> { pub fn ARC<T: Const Send>(+data: T) -> ARC<T> {
ARC { x: unsafe { shared_mutable_state(move data) } } ARC { x: unsafe { shared_mutable_state(move data) } }
} }
@ -79,7 +74,7 @@ fn ARC<T: Const Send>(+data: T) -> ARC<T> {
* Access the underlying data in an atomically reference counted * Access the underlying data in an atomically reference counted
* wrapper. * wrapper.
*/ */
fn get<T: Const Send>(rc: &a/ARC<T>) -> &a/T { pub fn get<T: Const Send>(rc: &a/ARC<T>) -> &a/T {
unsafe { get_shared_immutable_state(&rc.x) } unsafe { get_shared_immutable_state(&rc.x) }
} }
@ -90,7 +85,7 @@ fn get<T: Const Send>(rc: &a/ARC<T>) -> &a/T {
* object. However, one of the `arc` objects can be sent to another task, * object. However, one of the `arc` objects can be sent to another task,
* allowing them to share the underlying data. * allowing them to share the underlying data.
*/ */
fn clone<T: Const Send>(rc: &ARC<T>) -> ARC<T> { pub fn clone<T: Const Send>(rc: &ARC<T>) -> ARC<T> {
ARC { x: unsafe { clone_shared_mutable_state(&rc.x) } } ARC { x: unsafe { clone_shared_mutable_state(&rc.x) } }
} }
@ -118,14 +113,14 @@ struct MutexARCInner<T: Send> { lock: Mutex, failed: bool, data: T }
struct MutexARC<T: Send> { x: SharedMutableState<MutexARCInner<T>> } struct MutexARC<T: Send> { x: SharedMutableState<MutexARCInner<T>> }
/// Create a mutex-protected ARC with the supplied data. /// Create a mutex-protected ARC with the supplied data.
fn MutexARC<T: Send>(+user_data: T) -> MutexARC<T> { pub fn MutexARC<T: Send>(+user_data: T) -> MutexARC<T> {
mutex_arc_with_condvars(move user_data, 1) mutex_arc_with_condvars(move user_data, 1)
} }
/** /**
* Create a mutex-protected ARC with the supplied data and a specified number * Create a mutex-protected ARC with the supplied data and a specified number
* of condvars (as sync::mutex_with_condvars). * of condvars (as sync::mutex_with_condvars).
*/ */
fn mutex_arc_with_condvars<T: Send>(+user_data: T, pub fn mutex_arc_with_condvars<T: Send>(+user_data: T,
num_condvars: uint) -> MutexARC<T> { num_condvars: uint) -> MutexARC<T> {
let data = let data =
MutexARCInner { lock: mutex_with_condvars(num_condvars), MutexARCInner { lock: mutex_with_condvars(num_condvars),
@ -196,7 +191,7 @@ impl<T: Send> &MutexARC<T> {
* Will additionally fail if another task has failed while accessing the arc. * Will additionally fail if another task has failed while accessing the arc.
*/ */
// FIXME(#2585) make this a by-move method on the arc // FIXME(#2585) make this a by-move method on the arc
fn unwrap_mutex_arc<T: Send>(+arc: MutexARC<T>) -> T { pub fn unwrap_mutex_arc<T: Send>(+arc: MutexARC<T>) -> T {
let MutexARC { x: x } <- arc; let MutexARC { x: x } <- arc;
let inner = unsafe { unwrap_shared_mutable_state(move x) }; let inner = unsafe { unwrap_shared_mutable_state(move x) };
let MutexARCInner { failed: failed, data: data, _ } <- inner; let MutexARCInner { failed: failed, data: data, _ } <- inner;
@ -252,14 +247,14 @@ struct RWARC<T: Const Send> {
} }
/// Create a reader/writer ARC with the supplied data. /// Create a reader/writer ARC with the supplied data.
fn RWARC<T: Const Send>(+user_data: T) -> RWARC<T> { pub fn RWARC<T: Const Send>(+user_data: T) -> RWARC<T> {
rw_arc_with_condvars(move user_data, 1) rw_arc_with_condvars(move user_data, 1)
} }
/** /**
* Create a reader/writer ARC with the supplied data and a specified number * Create a reader/writer ARC with the supplied data and a specified number
* of condvars (as sync::rwlock_with_condvars). * of condvars (as sync::rwlock_with_condvars).
*/ */
fn rw_arc_with_condvars<T: Const Send>(+user_data: T, pub fn rw_arc_with_condvars<T: Const Send>(+user_data: T,
num_condvars: uint) -> RWARC<T> { num_condvars: uint) -> RWARC<T> {
let data = let data =
RWARCInner { lock: rwlock_with_condvars(num_condvars), RWARCInner { lock: rwlock_with_condvars(num_condvars),
@ -374,7 +369,7 @@ impl<T: Const Send> &RWARC<T> {
* in write mode. * in write mode.
*/ */
// FIXME(#2585) make this a by-move method on the arc // FIXME(#2585) make this a by-move method on the arc
fn unwrap_rw_arc<T: Const Send>(+arc: RWARC<T>) -> T { pub fn unwrap_rw_arc<T: Const Send>(+arc: RWARC<T>) -> T {
let RWARC { x: x, _ } <- arc; let RWARC { x: x, _ } <- arc;
let inner = unsafe { unwrap_shared_mutable_state(move x) }; let inner = unsafe { unwrap_shared_mutable_state(move x) };
let RWARCInner { failed: failed, data: data, _ } <- inner; let RWARCInner { failed: failed, data: data, _ } <- inner;
@ -395,10 +390,10 @@ fn borrow_rwlock<T: Const Send>(state: &r/mut RWARCInner<T>) -> &r/RWlock {
// FIXME (#3154) ice with struct/&<T> prevents these from being structs. // FIXME (#3154) ice with struct/&<T> prevents these from being structs.
/// The "write permission" token used for RWARC.write_downgrade(). /// The "write permission" token used for RWARC.write_downgrade().
enum RWWriteMode<T: Const Send> = pub enum RWWriteMode<T: Const Send> =
(&mut T, sync::RWlockWriteMode, PoisonOnFail); (&mut T, sync::RWlockWriteMode, PoisonOnFail);
/// The "read permission" token used for RWARC.write_downgrade(). /// The "read permission" token used for RWARC.write_downgrade().
enum RWReadMode<T:Const Send> = (&T, sync::RWlockReadMode); pub enum RWReadMode<T:Const Send> = (&T, sync::RWlockReadMode);
impl<T: Const Send> &RWWriteMode<T> { impl<T: Const Send> &RWWriteMode<T> {
/// Access the pre-downgrade RWARC in write mode. /// Access the pre-downgrade RWARC in write mode.

View file

@ -9,10 +9,8 @@ Higher level communication abstractions.
use pipes::{Channel, Recv, Chan, Port, Selectable}; use pipes::{Channel, Recv, Chan, Port, Selectable};
export DuplexStream;
/// An extension of `pipes::stream` that allows both sending and receiving. /// An extension of `pipes::stream` that allows both sending and receiving.
struct DuplexStream<T: Send, U: Send> { pub struct DuplexStream<T: Send, U: Send> {
priv chan: Chan<T>, priv chan: Chan<T>,
priv port: Port <U>, priv port: Port <U>,
} }

View file

@ -74,11 +74,8 @@ mod cell;
// Concurrency // Concurrency
#[legacy_exports]
mod sync; mod sync;
#[legacy_exports]
mod arc; mod arc;
#[legacy_exports]
mod comm; mod comm;
// Collections // Collections

View file

@ -7,9 +7,6 @@
* in std. * in std.
*/ */
export Condvar, Semaphore, Mutex, mutex_with_condvars;
export RWlock, rwlock_with_condvars, RWlockReadMode, RWlockWriteMode;
use private::{Exclusive, exclusive}; use private::{Exclusive, exclusive};
/**************************************************************************** /****************************************************************************
@ -176,7 +173,7 @@ fn SemAndSignalRelease(sem: &r/Sem<~[mut Waitqueue]>)
} }
/// A mechanism for atomic-unlock-and-deschedule blocking and signalling. /// A mechanism for atomic-unlock-and-deschedule blocking and signalling.
struct Condvar { priv sem: &Sem<~[mut Waitqueue]>, drop { } } pub struct Condvar { priv sem: &Sem<~[mut Waitqueue]>, drop { } }
impl &Condvar { impl &Condvar {
/** /**
@ -379,14 +376,14 @@ impl &Semaphore {
struct Mutex { priv sem: Sem<~[mut Waitqueue]> } struct Mutex { priv sem: Sem<~[mut Waitqueue]> }
/// Create a new mutex, with one associated condvar. /// Create a new mutex, with one associated condvar.
fn Mutex() -> Mutex { mutex_with_condvars(1) } pub fn Mutex() -> Mutex { mutex_with_condvars(1) }
/** /**
* Create a new mutex, with a specified number of associated condvars. This * Create a new mutex, with a specified number of associated condvars. This
* will allow calling wait_on/signal_on/broadcast_on with condvar IDs between * will allow calling wait_on/signal_on/broadcast_on with condvar IDs between
* 0 and num_condvars-1. (If num_condvars is 0, lock_cond will be allowed but * 0 and num_condvars-1. (If num_condvars is 0, lock_cond will be allowed but
* any operations on the condvar will fail.) * any operations on the condvar will fail.)
*/ */
fn mutex_with_condvars(num_condvars: uint) -> Mutex { pub fn mutex_with_condvars(num_condvars: uint) -> Mutex {
Mutex { sem: new_sem_and_signal(1, num_condvars) } Mutex { sem: new_sem_and_signal(1, num_condvars) }
} }
@ -429,13 +426,13 @@ struct RWlock {
} }
/// Create a new rwlock, with one associated condvar. /// Create a new rwlock, with one associated condvar.
fn RWlock() -> RWlock { rwlock_with_condvars(1) } pub fn RWlock() -> RWlock { rwlock_with_condvars(1) }
/** /**
* Create a new rwlock, with a specified number of associated condvars. * Create a new rwlock, with a specified number of associated condvars.
* Similar to mutex_with_condvars. * Similar to mutex_with_condvars.
*/ */
fn rwlock_with_condvars(num_condvars: uint) -> RWlock { pub fn rwlock_with_condvars(num_condvars: uint) -> RWlock {
RWlock { order_lock: semaphore(1), RWlock { order_lock: semaphore(1),
access_lock: new_sem_and_signal(1, num_condvars), access_lock: new_sem_and_signal(1, num_condvars),
state: exclusive(RWlockInner { read_mode: false, state: exclusive(RWlockInner { read_mode: false,
@ -646,9 +643,9 @@ fn RWlockReleaseDowngrade(lock: &r/RWlock) -> RWlockReleaseDowngrade/&r {
} }
/// The "write permission" token used for rwlock.write_downgrade(). /// The "write permission" token used for rwlock.write_downgrade().
struct RWlockWriteMode { /* priv */ lock: &RWlock, drop { } } pub struct RWlockWriteMode { /* priv */ lock: &RWlock, drop { } }
/// The "read permission" token used for rwlock.write_downgrade(). /// The "read permission" token used for rwlock.write_downgrade().
struct RWlockReadMode { priv lock: &RWlock, drop { } } pub struct RWlockReadMode { priv lock: &RWlock, drop { } }
impl &RWlockWriteMode { impl &RWlockWriteMode {
/// Access the pre-downgrade rwlock in write mode. /// Access the pre-downgrade rwlock in write mode.