From f3a7ec7028c76b3a1c6051131328f372b068e33a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 29 Dec 2014 15:03:01 -0800 Subject: std: Second pass stabilization of sync This pass performs a second pass of stabilization through the `std::sync` module, avoiding modules/types that are being handled in other PRs (e.g. mutexes, rwlocks, condvars, and channels). The following items are now stable * `sync::atomic` * `sync::atomic::ATOMIC_BOOL_INIT` (was `INIT_ATOMIC_BOOL`) * `sync::atomic::ATOMIC_INT_INIT` (was `INIT_ATOMIC_INT`) * `sync::atomic::ATOMIC_UINT_INIT` (was `INIT_ATOMIC_UINT`) * `sync::Once` * `sync::ONCE_INIT` * `sync::Once::call_once` (was `doit`) * C == `pthread_once(..)` * Boost == `call_once(..)` * Windows == `InitOnceExecuteOnce` * `sync::Barrier` * `sync::Barrier::new` * `sync::Barrier::wait` (now returns a `bool`) * `sync::Semaphore::new` * `sync::Semaphore::acquire` * `sync::Semaphore::release` The following items remain unstable * `sync::SemaphoreGuard` * `sync::Semaphore::access` - it's unclear how this relates to the poisoning story of mutexes. * `sync::TaskPool` - the semantics of a failing task and whether a thread is re-attached to a thread pool are somewhat unclear, and the utility of this type in `sync` is question with respect to the jobs of other primitives. This type will likely become stable or move out of the standard library over time. * `sync::Future` - futures as-is have yet to be deeply re-evaluated with the recent core changes to Rust's synchronization story, and will likely become stable in the future but are unstable until that time comes. [breaking-change] --- src/libstd/io/buffered.rs | 6 ------ src/libstd/io/stdio.rs | 2 +- src/libstd/io/tempfile.rs | 2 +- src/libstd/io/test.rs | 6 +++--- 4 files changed, 5 insertions(+), 11 deletions(-) (limited to 'src/libstd/io') diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index c5405601048..aa05c65ce76 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -22,7 +22,6 @@ use result::Result::{Ok, Err}; use slice::{SliceExt}; use slice; use vec::Vec; -use kinds::{Send,Sync}; /// Wraps a Reader and buffers input from it /// @@ -52,11 +51,6 @@ pub struct BufferedReader { cap: uint, } - -unsafe impl Send for BufferedReader {} -unsafe impl Sync for BufferedReader {} - - impl BufferedReader { /// Creates a new `BufferedReader` with the specified buffer capacity pub fn with_capacity(cap: uint, inner: R) -> BufferedReader { diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index b7d069eb19e..c76d68a01be 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -218,7 +218,7 @@ pub fn stdin() -> StdinReader { static ONCE: Once = ONCE_INIT; unsafe { - ONCE.doit(|| { + ONCE.call_once(|| { // The default buffer capacity is 64k, but apparently windows doesn't like // 64k reads on stdin. See #13304 for details, but the idea is that on // windows we use a slightly smaller buffer that's been seen to be diff --git a/src/libstd/io/tempfile.rs b/src/libstd/io/tempfile.rs index c2b4d5a1fa9..5cf86676651 100644 --- a/src/libstd/io/tempfile.rs +++ b/src/libstd/io/tempfile.rs @@ -90,7 +90,7 @@ impl TempDir { return TempDir::new_in(&abs_tmpdir, suffix); } - static CNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT; + static CNT: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT; let mut attempts = 0u; loop { diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs index 40941fda79c..3055359538b 100644 --- a/src/libstd/io/test.rs +++ b/src/libstd/io/test.rs @@ -16,17 +16,17 @@ use libc; use os; use prelude::*; use std::io::net::ip::*; -use sync::atomic::{AtomicUint, INIT_ATOMIC_UINT, Relaxed}; +use sync::atomic::{AtomicUint, ATOMIC_UINT_INIT, Relaxed}; /// Get a port number, starting at 9600, for use in tests pub fn next_test_port() -> u16 { - static NEXT_OFFSET: AtomicUint = INIT_ATOMIC_UINT; + static NEXT_OFFSET: AtomicUint = ATOMIC_UINT_INIT; base_port() + NEXT_OFFSET.fetch_add(1, Relaxed) as u16 } /// Get a temporary path which could be the location of a unix socket pub fn next_test_unix() -> Path { - static COUNT: AtomicUint = INIT_ATOMIC_UINT; + static COUNT: AtomicUint = ATOMIC_UINT_INIT; // base port and pid are an attempt to be unique between multiple // test-runners of different configurations running on one // buildbot, the count is to be unique within this executable. -- cgit 1.4.1-3-g733a5