auto merge of #19255 : aturon/rust/merge-sync, r=alexcrichton,alexcrichton
This patch merges the `libsync` crate into `libstd`, undoing part of the facade. This is in preparation for ultimately merging `librustrt`, as well as the upcoming rewrite of `sync`. Because this removes the `libsync` crate, it is a: [breaking-change] However, all uses of `libsync` should be able to reroute through `std::sync` and `std::comm` instead. r? @alexcrichton
This commit is contained in:
commit
689ef2dabf
@ -50,7 +50,7 @@
|
||||
################################################################################
|
||||
|
||||
TARGET_CRATES := libc std flate arena term \
|
||||
serialize sync getopts collections test time rand \
|
||||
serialize getopts collections test time rand \
|
||||
log regex graphviz core rbml alloc rustrt \
|
||||
unicode
|
||||
HOST_CRATES := syntax rustc rustc_trans rustdoc regex_macros fmt_macros \
|
||||
@ -63,7 +63,7 @@ DEPS_libc := core
|
||||
DEPS_unicode := core
|
||||
DEPS_alloc := core libc native:jemalloc
|
||||
DEPS_rustrt := alloc core libc collections native:rustrt_native
|
||||
DEPS_std := core libc rand alloc collections rustrt sync unicode \
|
||||
DEPS_std := core libc rand alloc collections rustrt unicode \
|
||||
native:rust_builtin native:backtrace
|
||||
DEPS_graphviz := std
|
||||
DEPS_syntax := std term serialize log fmt_macros arena libc
|
||||
@ -81,7 +81,6 @@ DEPS_glob := std
|
||||
DEPS_serialize := std log
|
||||
DEPS_rbml := std log serialize
|
||||
DEPS_term := std log
|
||||
DEPS_sync := core alloc rustrt collections
|
||||
DEPS_getopts := std
|
||||
DEPS_collections := core alloc unicode
|
||||
DEPS_num := std
|
||||
|
@ -38,10 +38,9 @@ exceptions = [
|
||||
"rt/isaac/randport.cpp", # public domain
|
||||
"rt/isaac/rand.h", # public domain
|
||||
"rt/isaac/standard.h", # public domain
|
||||
"libsync/mpsc_queue.rs", # BSD
|
||||
"libsync/spsc_queue.rs", # BSD
|
||||
"libsync/mpmc_bounded_queue.rs", # BSD
|
||||
"libsync/mpsc_intrusive.rs", # BSD
|
||||
"libstd/sync/mpsc_queue.rs", # BSD
|
||||
"libstd/sync/spsc_queue.rs", # BSD
|
||||
"libstd/sync/mpmc_bounded_queue.rs", # BSD
|
||||
"test/bench/shootout-binarytrees.rs", # BSD
|
||||
"test/bench/shootout-chameneos-redux.rs", # BSD
|
||||
"test/bench/shootout-fannkuch-redux.rs", # BSD
|
||||
|
@ -338,12 +338,11 @@ mod $name {
|
||||
|
||||
extern crate rustrt;
|
||||
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
|
||||
use comm::*;
|
||||
use super::*;
|
||||
use super::super::*;
|
||||
use std::task;
|
||||
use task;
|
||||
|
||||
$(#[$a])* #[test] fn f() { $b }
|
||||
}
|
||||
@ -1019,9 +1018,9 @@ fn drop(&mut self) {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
|
||||
use std::os;
|
||||
use os;
|
||||
use super::*;
|
||||
|
||||
pub fn stress_factor() -> uint {
|
||||
@ -1554,8 +1553,8 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
|
||||
|
||||
#[cfg(test)]
|
||||
mod sync_tests {
|
||||
use std::prelude::*;
|
||||
use std::os;
|
||||
use prelude::*;
|
||||
use os;
|
||||
|
||||
pub fn stress_factor() -> uint {
|
||||
match os::getenv("RUST_TEST_STRESS") {
|
@ -44,7 +44,7 @@
|
||||
use rustrt::local::Local;
|
||||
use rustrt::task::{Task, BlockedTask};
|
||||
|
||||
use atomic;
|
||||
use sync::atomic;
|
||||
use comm::Receiver;
|
||||
|
||||
// Various states you can find a port in.
|
@ -325,9 +325,9 @@ fn next(&mut self) -> Option<*mut Handle<'static, ()>> {
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
|
||||
use super::super::*;
|
||||
use super::*;
|
||||
|
||||
// Don't use the libstd version so we can pull in the right Select structure
|
||||
// (std::comm points at the wrong one)
|
@ -30,8 +30,8 @@
|
||||
use rustrt::task::{Task, BlockedTask};
|
||||
use rustrt::thread::Thread;
|
||||
|
||||
use atomic;
|
||||
use mpsc_queue as mpsc;
|
||||
use sync::atomic;
|
||||
use sync::mpsc_queue as mpsc;
|
||||
|
||||
const DISCONNECTED: int = int::MIN;
|
||||
const FUDGE: int = 1024;
|
@ -31,9 +31,9 @@
|
||||
use rustrt::task::{Task, BlockedTask};
|
||||
use rustrt::thread::Thread;
|
||||
|
||||
use atomic;
|
||||
use sync::atomic;
|
||||
use sync::spsc_queue as spsc;
|
||||
use comm::Receiver;
|
||||
use spsc_queue as spsc;
|
||||
|
||||
const DISCONNECTED: int = int::MIN;
|
||||
#[cfg(test)]
|
@ -39,14 +39,14 @@
|
||||
use self::Blocker::*;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use collections::Vec;
|
||||
use vec::Vec;
|
||||
use core::mem;
|
||||
use core::cell::UnsafeCell;
|
||||
use rustrt::local::Local;
|
||||
use rustrt::mutex::{NativeMutex, LockGuard};
|
||||
use rustrt::task::{Task, BlockedTask};
|
||||
|
||||
use atomic;
|
||||
use sync::atomic;
|
||||
|
||||
pub struct Packet<T> {
|
||||
/// Only field outside of the mutex. Just done for kicks, but mainly because
|
@ -124,7 +124,6 @@
|
||||
extern crate core;
|
||||
extern crate "collections" as core_collections;
|
||||
extern crate "rand" as core_rand;
|
||||
extern crate "sync" as core_sync;
|
||||
extern crate libc;
|
||||
extern crate rustrt;
|
||||
|
||||
@ -173,8 +172,6 @@
|
||||
|
||||
pub use unicode::char;
|
||||
|
||||
pub use core_sync::comm;
|
||||
|
||||
/* Exported macros */
|
||||
|
||||
pub mod macros;
|
||||
@ -236,6 +233,7 @@
|
||||
|
||||
pub mod task;
|
||||
pub mod sync;
|
||||
pub mod comm;
|
||||
|
||||
#[cfg(unix)]
|
||||
#[path = "sys/unix/mod.rs"] mod sys;
|
||||
|
@ -178,7 +178,7 @@ fn drop(&mut self) {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
@ -57,13 +57,13 @@
|
||||
use alloc::arc::Arc;
|
||||
use alloc::heap::{allocate, deallocate};
|
||||
use alloc::boxed::Box;
|
||||
use collections::Vec;
|
||||
use vec::Vec;
|
||||
use core::kinds::marker;
|
||||
use core::mem::{forget, min_align_of, size_of, transmute};
|
||||
use core::ptr;
|
||||
use rustrt::exclusive::Exclusive;
|
||||
|
||||
use atomic::{AtomicInt, AtomicPtr, SeqCst};
|
||||
use sync::atomic::{AtomicInt, AtomicPtr, SeqCst};
|
||||
|
||||
// Once the queue is less than 1/K full, then it will be downsized. Note that
|
||||
// the deque requires that this number be less than 2.
|
||||
@ -410,16 +410,16 @@ fn drop(&mut self) {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
use super::{Data, BufferPool, Abort, Empty, Worker, Stealer};
|
||||
|
||||
use std::mem;
|
||||
use mem;
|
||||
use rustrt::thread::Thread;
|
||||
use std::rand;
|
||||
use std::rand::Rng;
|
||||
use atomic::{AtomicBool, INIT_ATOMIC_BOOL, SeqCst,
|
||||
AtomicUint, INIT_ATOMIC_UINT};
|
||||
use std::vec;
|
||||
use rand;
|
||||
use rand::Rng;
|
||||
use sync::atomic::{AtomicBool, INIT_ATOMIC_BOOL, SeqCst,
|
||||
AtomicUint, INIT_ATOMIC_UINT};
|
||||
use vec;
|
||||
|
||||
#[test]
|
||||
fn smoke() {
|
@ -27,7 +27,7 @@
|
||||
use rustrt::local::Local;
|
||||
use rustrt::task::Task;
|
||||
|
||||
use raw;
|
||||
use super::raw;
|
||||
|
||||
/****************************************************************************
|
||||
* Poisoning helpers
|
||||
@ -158,7 +158,7 @@ pub fn broadcast_on(&self, condvar_id: uint) -> uint {
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use sync::{Mutex, Arc};
|
||||
/// use std::sync::{Mutex, Arc};
|
||||
///
|
||||
/// let mutex = Arc::new(Mutex::new(1i));
|
||||
/// let mutex2 = mutex.clone();
|
||||
@ -259,7 +259,7 @@ fn deref_mut<'a>(&'a mut self) -> &'a mut T { &mut *self._data }
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use sync::{RWLock, Arc};
|
||||
/// use std::sync::{RWLock, Arc};
|
||||
///
|
||||
/// let lock1 = Arc::new(RWLock::new(1i));
|
||||
/// let lock2 = lock1.clone();
|
||||
@ -395,7 +395,7 @@ fn deref_mut<'a>(&'a mut self) -> &'a mut T { &mut *self._data }
|
||||
/// of some computation.
|
||||
///
|
||||
/// ```rust
|
||||
/// use sync::{Arc, Barrier};
|
||||
/// use std::sync::{Arc, Barrier};
|
||||
///
|
||||
/// let barrier = Arc::new(Barrier::new(10));
|
||||
/// for _ in range(0u, 10) {
|
||||
@ -458,12 +458,12 @@ pub fn wait(&self) {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::prelude::*;
|
||||
use std::comm::Empty;
|
||||
use std::task;
|
||||
use std::task::try_future;
|
||||
use prelude::*;
|
||||
use comm::Empty;
|
||||
use task;
|
||||
use task::try_future;
|
||||
use sync::Arc;
|
||||
|
||||
use Arc;
|
||||
use super::{Mutex, Barrier, RWLock};
|
||||
|
||||
#[test]
|
@ -17,17 +17,41 @@
|
||||
|
||||
#![experimental]
|
||||
|
||||
#[stable]
|
||||
pub use core_sync::atomic;
|
||||
pub use self::one::{Once, ONCE_INIT};
|
||||
|
||||
pub use core_sync::{deque, mpmc_bounded_queue, mpsc_queue, spsc_queue};
|
||||
pub use core_sync::{Arc, Weak, Mutex, MutexGuard, Condvar, Barrier};
|
||||
pub use core_sync::{RWLock, RWLockReadGuard, RWLockWriteGuard};
|
||||
pub use core_sync::{Semaphore, SemaphoreGuard};
|
||||
pub use core_sync::one::{Once, ONCE_INIT};
|
||||
pub use alloc::arc::{Arc, Weak};
|
||||
pub use self::lock::{Mutex, MutexGuard, Condvar, Barrier,
|
||||
RWLock, RWLockReadGuard, RWLockWriteGuard};
|
||||
|
||||
// The mutex/rwlock in this module are not meant for reexport
|
||||
pub use self::raw::{Semaphore, SemaphoreGuard};
|
||||
|
||||
pub use self::future::Future;
|
||||
pub use self::task_pool::TaskPool;
|
||||
|
||||
// Core building blocks for all primitives in this crate
|
||||
|
||||
#[stable]
|
||||
pub mod atomic;
|
||||
|
||||
// Concurrent data structures
|
||||
|
||||
pub mod spsc_queue;
|
||||
pub mod mpsc_queue;
|
||||
pub mod mpmc_bounded_queue;
|
||||
pub mod deque;
|
||||
|
||||
// Low-level concurrency primitives
|
||||
|
||||
mod raw;
|
||||
mod mutex;
|
||||
mod one;
|
||||
|
||||
// Higher level primitives based on those above
|
||||
|
||||
mod lock;
|
||||
|
||||
// Task management
|
||||
|
||||
mod future;
|
||||
mod task_pool;
|
||||
|
@ -33,11 +33,11 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use alloc::arc::Arc;
|
||||
use collections::Vec;
|
||||
use vec::Vec;
|
||||
use core::num::UnsignedInt;
|
||||
use core::cell::UnsafeCell;
|
||||
|
||||
use atomic::{AtomicUint,Relaxed,Release,Acquire};
|
||||
use sync::atomic::{AtomicUint,Relaxed,Release,Acquire};
|
||||
|
||||
struct Node<T> {
|
||||
sequence: AtomicUint,
|
||||
@ -165,7 +165,7 @@ fn clone(&self) -> Queue<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
use super::Queue;
|
||||
|
||||
#[test]
|
@ -48,7 +48,7 @@
|
||||
use core::mem;
|
||||
use core::cell::UnsafeCell;
|
||||
|
||||
use atomic::{AtomicPtr, Release, Acquire, AcqRel, Relaxed};
|
||||
use sync::atomic::{AtomicPtr, Release, Acquire, AcqRel, Relaxed};
|
||||
|
||||
/// A result of the `pop` function.
|
||||
pub enum PopResult<T> {
|
||||
@ -159,7 +159,7 @@ fn drop(&mut self) {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
|
||||
use alloc::arc::Arc;
|
||||
|
@ -28,8 +28,8 @@
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use sync::mutex::Mutex;
|
||||
/// ```rust,ignore
|
||||
/// use std::sync::mutex::Mutex;
|
||||
///
|
||||
/// let m = Mutex::new();
|
||||
/// let guard = m.lock();
|
||||
@ -57,8 +57,8 @@ pub struct Mutex {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use sync::mutex::{StaticMutex, MUTEX_INIT};
|
||||
/// ```rust,ignore
|
||||
/// use std::sync::mutex::{StaticMutex, MUTEX_INIT};
|
||||
///
|
||||
/// static LOCK: StaticMutex = MUTEX_INIT;
|
||||
///
|
||||
@ -156,7 +156,7 @@ fn drop(&mut self) {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
use super::{Mutex, StaticMutex, MUTEX_INIT};
|
||||
|
||||
#[test]
|
@ -18,7 +18,7 @@
|
||||
use core::int;
|
||||
use core::atomic;
|
||||
|
||||
use mutex::{StaticMutex, MUTEX_INIT};
|
||||
use super::mutex::{StaticMutex, MUTEX_INIT};
|
||||
|
||||
/// A synchronization primitive which can be used to run a one-time global
|
||||
/// initialization. Useful for one-time initialization for FFI or related
|
||||
@ -27,8 +27,8 @@
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use sync::one::{Once, ONCE_INIT};
|
||||
/// ```rust,ignore
|
||||
/// use std::sync::one::{Once, ONCE_INIT};
|
||||
///
|
||||
/// static START: Once = ONCE_INIT;
|
||||
///
|
||||
@ -120,8 +120,8 @@ pub fn doit(&self, f: ||) {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use std::task;
|
||||
use prelude::*;
|
||||
use task;
|
||||
use super::{ONCE_INIT, Once};
|
||||
|
||||
#[test]
|
@ -15,6 +15,10 @@
|
||||
//! `sync` crate which wrap values directly and provide safer abstractions for
|
||||
//! containing data.
|
||||
|
||||
// A side-effect of merging libsync into libstd; will go away once
|
||||
// libsync rewrite lands
|
||||
#![allow(dead_code)]
|
||||
|
||||
use core::prelude::*;
|
||||
use self::ReacquireOrderLock::*;
|
||||
|
||||
@ -23,9 +27,9 @@
|
||||
use core::kinds::marker;
|
||||
use core::mem;
|
||||
use core::cell::UnsafeCell;
|
||||
use collections::Vec;
|
||||
use vec::Vec;
|
||||
|
||||
use mutex;
|
||||
use super::mutex;
|
||||
use comm::{Receiver, Sender, channel};
|
||||
|
||||
/****************************************************************************
|
||||
@ -518,8 +522,8 @@ pub fn read<'a>(&'a self) -> RWLockReadGuard<'a> {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use sync::raw::RWLock;
|
||||
/// ```{rust,ignore}
|
||||
/// use std::sync::raw::RWLock;
|
||||
///
|
||||
/// let lock = RWLock::new();
|
||||
/// let write = lock.write();
|
||||
@ -622,14 +626,13 @@ fn drop(&mut self) {
|
||||
mod tests {
|
||||
pub use self::RWLockMode::*;
|
||||
|
||||
use std::prelude::*;
|
||||
|
||||
use Arc;
|
||||
use sync::Arc;
|
||||
use prelude::*;
|
||||
use super::{Semaphore, Mutex, RWLock, Condvar};
|
||||
|
||||
use std::mem;
|
||||
use std::result;
|
||||
use std::task;
|
||||
use mem;
|
||||
use result;
|
||||
use task;
|
||||
|
||||
/************************************************************************
|
||||
* Semaphore tests
|
||||
@ -837,7 +840,7 @@ fn test_mutex_cond_no_waiter() {
|
||||
}
|
||||
#[test]
|
||||
fn test_mutex_killed_simple() {
|
||||
use std::any::Any;
|
||||
use any::Any;
|
||||
|
||||
// Mutex must get automatically unlocked if panicked/killed within.
|
||||
let m = Arc::new(Mutex::new());
|
||||
@ -1077,7 +1080,7 @@ fn test_rwlock_cond_broadcast() {
|
||||
}
|
||||
#[cfg(test)]
|
||||
fn rwlock_kill_helper(mode1: RWLockMode, mode2: RWLockMode) {
|
||||
use std::any::Any;
|
||||
use any::Any;
|
||||
|
||||
// Mutex must get automatically unlocked if panicked/killed within.
|
||||
let x = Arc::new(RWLock::new());
|
@ -42,7 +42,7 @@
|
||||
use core::cell::UnsafeCell;
|
||||
use alloc::arc::Arc;
|
||||
|
||||
use atomic::{AtomicPtr, Relaxed, AtomicUint, Acquire, Release};
|
||||
use sync::atomic::{AtomicPtr, Relaxed, AtomicUint, Acquire, Release};
|
||||
|
||||
// Node within the linked list queue of messages to send
|
||||
struct Node<T> {
|
||||
@ -294,7 +294,7 @@ fn drop(&mut self) {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use prelude::*;
|
||||
|
||||
use super::{queue};
|
||||
|
@ -1,78 +0,0 @@
|
||||
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! Core concurrency-enabled mechanisms and primitives.
|
||||
//!
|
||||
//! This crate contains the implementations of Rust's core synchronization
|
||||
//! primitives. This includes channels, mutexes, condition variables, etc.
|
||||
//!
|
||||
//! The interface of this crate is experimental, and it is not recommended to
|
||||
//! use this crate specifically. Instead, its functionality is reexported
|
||||
//! through `std::sync`.
|
||||
|
||||
#![crate_name = "sync"]
|
||||
#![experimental]
|
||||
#![crate_type = "rlib"]
|
||||
#![crate_type = "dylib"]
|
||||
#![license = "MIT/ASL2"]
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/",
|
||||
html_playground_url = "http://play.rust-lang.org/")]
|
||||
|
||||
#![feature(phase, globs, macro_rules, unsafe_destructor)]
|
||||
#![feature(import_shadowing)]
|
||||
#![deny(missing_docs)]
|
||||
#![no_std]
|
||||
|
||||
#[phase(plugin, link)] extern crate core;
|
||||
extern crate alloc;
|
||||
extern crate collections;
|
||||
extern crate rustrt;
|
||||
|
||||
#[cfg(test)] extern crate test;
|
||||
#[cfg(test)] #[phase(plugin, link)] extern crate std;
|
||||
|
||||
pub use alloc::arc::{Arc, Weak};
|
||||
pub use lock::{Mutex, MutexGuard, Condvar, Barrier,
|
||||
RWLock, RWLockReadGuard, RWLockWriteGuard};
|
||||
|
||||
// The mutex/rwlock in this module are not meant for reexport
|
||||
pub use raw::{Semaphore, SemaphoreGuard};
|
||||
|
||||
// Core building blocks for all primitives in this crate
|
||||
|
||||
pub mod atomic;
|
||||
|
||||
// Concurrent data structures
|
||||
|
||||
pub mod spsc_queue;
|
||||
pub mod mpsc_queue;
|
||||
pub mod mpmc_bounded_queue;
|
||||
pub mod deque;
|
||||
|
||||
// Low-level concurrency primitives
|
||||
|
||||
pub mod raw;
|
||||
pub mod mutex;
|
||||
pub mod one;
|
||||
|
||||
// Message-passing based communication
|
||||
|
||||
pub mod comm;
|
||||
|
||||
// Higher level primitives based on those above
|
||||
|
||||
mod lock;
|
||||
|
||||
#[cfg(not(test))]
|
||||
mod std {
|
||||
pub use core::{fmt, option, cmp, clone};
|
||||
}
|
Loading…
Reference in New Issue
Block a user