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,
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.
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 {
/// 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> }
/// 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) } }
}
@ -79,7 +74,7 @@ fn ARC<T: Const Send>(+data: T) -> ARC<T> {
* Access the underlying data in an atomically reference counted
* 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) }
}
@ -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,
* 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) } }
}
@ -118,14 +113,14 @@ struct MutexARCInner<T: Send> { lock: Mutex, failed: bool, data: T }
struct MutexARC<T: Send> { x: SharedMutableState<MutexARCInner<T>> }
/// 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)
}
/**
* Create a mutex-protected ARC with the supplied data and a specified number
* 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> {
let data =
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.
*/
// 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 inner = unsafe { unwrap_shared_mutable_state(move x) };
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.
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)
}
/**
* Create a reader/writer ARC with the supplied data and a specified number
* 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> {
let data =
RWARCInner { lock: rwlock_with_condvars(num_condvars),
@ -374,7 +369,7 @@ impl<T: Const Send> &RWARC<T> {
* in write mode.
*/
// 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 inner = unsafe { unwrap_shared_mutable_state(move x) };
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.
/// 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);
/// 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> {
/// 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};
export DuplexStream;
/// 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 port: Port <U>,
}

View File

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

View File

@ -7,9 +7,6 @@
* in std.
*/
export Condvar, Semaphore, Mutex, mutex_with_condvars;
export RWlock, rwlock_with_condvars, RWlockReadMode, RWlockWriteMode;
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.
struct Condvar { priv sem: &Sem<~[mut Waitqueue]>, drop { } }
pub struct Condvar { priv sem: &Sem<~[mut Waitqueue]>, drop { } }
impl &Condvar {
/**
@ -379,14 +376,14 @@ impl &Semaphore {
struct Mutex { priv sem: Sem<~[mut Waitqueue]> }
/// 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
* 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
* 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) }
}
@ -429,13 +426,13 @@ struct RWlock {
}
/// 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.
* 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),
access_lock: new_sem_and_signal(1, num_condvars),
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().
struct RWlockWriteMode { /* priv */ lock: &RWlock, drop { } }
pub struct RWlockWriteMode { /* priv */ lock: &RWlock, drop { } }
/// The "read permission" token used for rwlock.write_downgrade().
struct RWlockReadMode { priv lock: &RWlock, drop { } }
pub struct RWlockReadMode { priv lock: &RWlock, drop { } }
impl &RWlockWriteMode {
/// Access the pre-downgrade rwlock in write mode.