]> git.lizzy.rs Git - rust.git/commitdiff
std: Second pass stabilization of sync
authorAlex Crichton <alex@alexcrichton.com>
Mon, 29 Dec 2014 23:03:01 +0000 (15:03 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 2 Jan 2015 06:02:59 +0000 (22:02 -0800)
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]

44 files changed:
src/doc/guide-tasks.md
src/doc/guide.md
src/doc/reference.md
src/libcollections/vec.rs
src/libcore/atomic.rs
src/libcore/cell.rs
src/libcoretest/atomic.rs
src/liblog/lib.rs
src/librustc/middle/infer/region_inference/graphviz.rs
src/librustc_trans/back/write.rs
src/librustc_trans/trans/base.rs
src/libstd/comm/blocking.rs
src/libstd/io/buffered.rs
src/libstd/io/stdio.rs
src/libstd/io/tempfile.rs
src/libstd/io/test.rs
src/libstd/os.rs
src/libstd/rand/os.rs
src/libstd/rt/backtrace.rs
src/libstd/rt/exclusive.rs [deleted file]
src/libstd/rt/unwind.rs
src/libstd/rt/util.rs
src/libstd/sync/atomic.rs
src/libstd/sync/barrier.rs
src/libstd/sync/condvar.rs
src/libstd/sync/future.rs
src/libstd/sync/mod.rs
src/libstd/sync/once.rs
src/libstd/sync/semaphore.rs
src/libstd/sync/task_pool.rs
src/libstd/sys/common/thread_local.rs
src/libstd/sys/unix/os.rs
src/libstd/sys/unix/pipe.rs
src/libstd/sys/unix/timer.rs
src/libstd/sys/windows/mod.rs
src/libstd/sys/windows/mutex.rs
src/libstd/time/mod.rs
src/libtime/lib.rs
src/test/auxiliary/issue-17718.rs
src/test/bench/shootout-binarytrees.rs
src/test/bench/shootout-fannkuch-redux.rs
src/test/compile-fail/std-uncopyable-atomics.rs
src/test/run-pass/issue-17718.rs
src/test/run-pass/vector-sort-panic-safe.rs

index 29c98e22ee9788d70fb19cecbcc0d9bb929ad5c4..8eb13187e5841b8d1595ca846b0d9606be8c2ef8 100644 (file)
@@ -206,6 +206,7 @@ getting the result later.
 The basic example below illustrates this.
 
 ```{rust,ignore}
+# #![allow(deprecated)]
 use std::sync::Future;
 
 # fn main() {
@@ -233,6 +234,7 @@ Here is another example showing how futures allow you to background
 computations. The workload will be distributed on the available cores.
 
 ```{rust,ignore}
+# #![allow(deprecated)]
 # use std::num::Float;
 # use std::sync::Future;
 fn partial_sum(start: uint) -> f64 {
index f4ec787a7949109c7a2a95801cfdf49ce958baa3..552ac31d0380887935b2f1afa845e394432b6c55 100644 (file)
@@ -5312,6 +5312,7 @@ example, if you wish to compute some value in the background, `Future` is
 a useful thing to use:
 
 ```{rust}
+# #![allow(deprecated)]
 use std::sync::Future;
 
 let mut delayed_value = Future::spawn(move || {
index f3ad19bbd2a6c038cdb2b2ea3ff730a054035cb4..0ce7c30d197aa3cbaac93a8b2dbc06a67978f731 100644 (file)
@@ -1480,9 +1480,9 @@ data are being stored, or single-address and mutability properties are required.
 ```
 use std::sync::atomic;
 
-// Note that INIT_ATOMIC_UINT is a *const*, but it may be used to initialize a
+// Note that ATOMIC_UINT_INIT is a *const*, but it may be used to initialize a
 // static. This static can be modified, so it is not placed in read-only memory.
-static COUNTER: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+static COUNTER: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT;
 
 // This table is a candidate to be placed in read-only memory.
 static TABLE: &'static [uint] = &[1, 2, 3, /* ... */];
index a1952352badfaa28115cfad197b07a9840bd463a..02a627c42ac6f774c798d4e9970583984a60253b 100644 (file)
@@ -2263,7 +2263,7 @@ fn drop(&mut self) {
             }
         }
         const NUM_ELEMENTS: uint = 2;
-        static DROP_COUNTER: AtomicUint = atomic::INIT_ATOMIC_UINT;
+        static DROP_COUNTER: AtomicUint = atomic::ATOMIC_UINT_INIT;
 
         let v = Vec::from_elem(NUM_ELEMENTS, Nothing);
 
index 6a40915f4dd829970102bf1a557827c5a9ff0957..f653998c9bf5d471db0b65a7856614ee9634da7a 100644 (file)
@@ -89,17 +89,27 @@ pub enum Ordering {
 
 /// An `AtomicBool` initialized to `false`.
 #[unstable = "may be renamed, pending conventions for static initalizers"]
-pub const INIT_ATOMIC_BOOL: AtomicBool =
+pub const ATOMIC_BOOL_INIT: AtomicBool =
         AtomicBool { v: UnsafeCell { value: 0 } };
 /// An `AtomicInt` initialized to `0`.
 #[unstable = "may be renamed, pending conventions for static initalizers"]
-pub const INIT_ATOMIC_INT: AtomicInt =
+pub const ATOMIC_INT_INIT: AtomicInt =
         AtomicInt { v: UnsafeCell { value: 0 } };
 /// An `AtomicUint` initialized to `0`.
 #[unstable = "may be renamed, pending conventions for static initalizers"]
-pub const INIT_ATOMIC_UINT: AtomicUint =
+pub const ATOMIC_UINT_INIT: AtomicUint =
         AtomicUint { v: UnsafeCell { value: 0, } };
 
+/// Deprecated
+#[deprecated = "renamed to ATOMIC_BOOL_INIT"]
+pub const INIT_ATOMIC_BOOL: AtomicBool = ATOMIC_BOOL_INIT;
+/// Deprecated
+#[deprecated = "renamed to ATOMIC_INT_INIT"]
+pub const INIT_ATOMIC_INT: AtomicInt = ATOMIC_INT_INIT;
+/// Deprecated
+#[deprecated = "renamed to ATOMIC_UINT_INIT"]
+pub const INIT_ATOMIC_UINT: AtomicUint = ATOMIC_UINT_INIT;
+
 // NB: Needs to be -1 (0b11111111...) to make fetch_nand work correctly
 const UINT_TRUE: uint = -1;
 
index 4b246860006abc5fc5819de36126b9ed69e57cbb..94e9441abc8b658ba33a76c38699a1fb1e944c7e 100644 (file)
 // FIXME: Can't be shared between threads. Dynamic borrows
 // FIXME: Relationship to Atomic types and RWLock
 
+#![stable]
+
 use clone::Clone;
 use cmp::PartialEq;
 use default::Default;
index 1fee304a9764890281b6bf7ce4f3c2864a1aebed..f8e943ec9f651a9bef01e5e5c2388dc6b24beabb 100644 (file)
@@ -70,9 +70,9 @@ fn int_xor() {
     assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
 }
 
-static S_BOOL : AtomicBool = INIT_ATOMIC_BOOL;
-static S_INT  : AtomicInt  = INIT_ATOMIC_INT;
-static S_UINT : AtomicUint = INIT_ATOMIC_UINT;
+static S_BOOL : AtomicBool = ATOMIC_BOOL_INIT;
+static S_INT  : AtomicInt  = ATOMIC_INT_INIT;
+static S_UINT : AtomicUint = ATOMIC_UINT_INIT;
 
 #[test]
 fn static_init() {
index b30938ae7f57770e1ca517e52a6314052c250ce5..4ee5b2d5e834991db0dcde74e74ceef76a1d92f2 100644 (file)
@@ -352,7 +352,7 @@ pub struct LogLocation {
 #[doc(hidden)]
 pub fn mod_enabled(level: u32, module: &str) -> bool {
     static INIT: Once = ONCE_INIT;
-    INIT.doit(init);
+    INIT.call_once(init);
 
     // It's possible for many threads are in this function, only one of them
     // will perform the global initialization, but all of them will need to check
index 8455ee3955bd06cefa8348dc34b4c3f89d859c5a..b6020fe5ce38bf3d142ff2b826ac408914e6235c 100644 (file)
@@ -73,7 +73,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
     let output_path = {
         let output_template = match requested_output {
             Some(ref s) if s.as_slice() == "help" => {
-                static PRINTED_YET : atomic::AtomicBool = atomic::INIT_ATOMIC_BOOL;
+                static PRINTED_YET : atomic::AtomicBool = atomic::ATOMIC_BOOL_INIT;
                 if !PRINTED_YET.load(atomic::SeqCst) {
                     print_help_message();
                     PRINTED_YET.store(true, atomic::SeqCst);
index a6f2c7dfed0b18cebf9a4e7b1cb0075cf64f8b2e..f2242b72aae321a098d919210d51b6fcfee7415e 100644 (file)
@@ -1009,7 +1009,7 @@ unsafe fn configure_llvm(sess: &Session) {
         }
     }
 
-    INIT.doit(|| {
+    INIT.call_once(|| {
         llvm::LLVMInitializePasses();
 
         // Only initialize the platforms supported by Rust here, because
index 475443654264f0471b40d42f259c4fa14d572195..18a3ce2ab729c9163d22e8caed851729547db607 100644 (file)
@@ -3097,7 +3097,7 @@ pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>)
         use std::sync::{Once, ONCE_INIT};
         static INIT: Once = ONCE_INIT;
         static mut POISONED: bool = false;
-        INIT.doit(|| {
+        INIT.call_once(|| {
             if llvm::LLVMStartMultithreaded() != 1 {
                 // use an extra bool to make sure that all future usage of LLVM
                 // cannot proceed despite the Once not running more than once.
index 412b7161305e68b12c2d9db7adc400ad1ad834fc..a529901272358604752c43e9d73e86fe907d5142 100644 (file)
@@ -11,7 +11,7 @@
 //! Generic support for building blocking abstractions.
 
 use thread::Thread;
-use sync::atomic::{AtomicBool, INIT_ATOMIC_BOOL, Ordering};
+use sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
 use sync::Arc;
 use kinds::{Sync, Send};
 use kinds::marker::{NoSend, NoSync};
@@ -40,7 +40,7 @@ pub struct WaitToken {
 pub fn tokens() -> (WaitToken, SignalToken) {
     let inner = Arc::new(Inner {
         thread: Thread::current(),
-        woken: INIT_ATOMIC_BOOL,
+        woken: ATOMIC_BOOL_INIT,
     });
     let wait_token = WaitToken {
         inner: inner.clone(),
index c5405601048cea55b9f88eb1eed3804d6474e297..aa05c65ce76cbb367c05f8be632f3782a34e7717 100644 (file)
@@ -22,7 +22,6 @@
 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<R> {
     cap: uint,
 }
 
-
-unsafe impl<R: Send> Send for BufferedReader<R> {}
-unsafe impl<R: Send+Sync> Sync for BufferedReader<R> {}
-
-
 impl<R: Reader> BufferedReader<R> {
     /// Creates a new `BufferedReader` with the specified buffer capacity
     pub fn with_capacity(cap: uint, inner: R) -> BufferedReader<R> {
index b7d069eb19e581313b203e57bd293078d5e5b23e..c76d68a01bedc410e1b67bae91cc7e6bd8c2939d 100644 (file)
@@ -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
index c2b4d5a1fa98241d776a68db3e15e279d242d404..5cf8667665162ebf34b84e81cd75eaba3b919bab 100644 (file)
@@ -90,7 +90,7 @@ pub fn new_in(tmpdir: &Path, suffix: &str) -> IoResult<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 {
index 40941fda79c93821cd3a604fc7a1516f48c68d90..3055359538bac82f4bfdb1ad4ec21ad7fa2ecc0d 100644 (file)
 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.
index df50b7f81afcf24d4c61c399cb90090d63a687d6..e470ee3cb4b0c3d310a4871e1e32584f61754eaf 100644 (file)
@@ -55,7 +55,7 @@
 use slice::CloneSliceExt;
 use str::{Str, StrExt};
 use string::{String, ToString};
-use sync::atomic::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
+use sync::atomic::{AtomicInt, ATOMIC_INT_INIT, SeqCst};
 use vec::Vec;
 
 #[cfg(unix)] use c_str::ToCStr;
@@ -596,7 +596,7 @@ pub fn last_os_error() -> String {
     error_string(errno() as uint)
 }
 
-static EXIT_STATUS: AtomicInt = INIT_ATOMIC_INT;
+static EXIT_STATUS: AtomicInt = ATOMIC_INT_INIT;
 
 /// Sets the process exit code
 ///
index ca36f2d8997b1df67dc3f00468a55753a1243132..46b9fe9657cea22c7a20a59084f4b7abd1c686f7 100644 (file)
@@ -84,10 +84,10 @@ fn getrandom_next_u64() -> u64 {
     #[cfg(all(target_os = "linux",
               any(target_arch = "x86_64", target_arch = "x86", target_arch = "arm")))]
     fn is_getrandom_available() -> bool {
-        use sync::atomic::{AtomicBool, INIT_ATOMIC_BOOL, Relaxed};
+        use sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Relaxed};
 
-        static GETRANDOM_CHECKED: AtomicBool = INIT_ATOMIC_BOOL;
-        static GETRANDOM_AVAILABLE: AtomicBool = INIT_ATOMIC_BOOL;
+        static GETRANDOM_CHECKED: AtomicBool = ATOMIC_BOOL_INIT;
+        static GETRANDOM_AVAILABLE: AtomicBool = ATOMIC_BOOL_INIT;
 
         if !GETRANDOM_CHECKED.load(Relaxed) {
             let mut buf: [u8; 0] = [];
index 3eeb0ad3968fe9b091e77cc9f4154d5466a98c4a..0b69486129aa69a7e3e3f61c4cd5e0f9d3b3cfb8 100644 (file)
@@ -22,7 +22,7 @@
 // For now logging is turned off by default, and this function checks to see
 // whether the magical environment variable is present to see if it's turned on.
 pub fn log_enabled() -> bool {
-    static ENABLED: atomic::AtomicInt = atomic::INIT_ATOMIC_INT;
+    static ENABLED: atomic::AtomicInt = atomic::ATOMIC_INT_INIT;
     match ENABLED.load(atomic::SeqCst) {
         1 => return false,
         2 => return true,
diff --git a/src/libstd/rt/exclusive.rs b/src/libstd/rt/exclusive.rs
deleted file mode 100644 (file)
index 88bdb29..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 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.
-
-use core::prelude::*;
-
-use cell::UnsafeCell;
-use rt::mutex;
-
-/// An OS mutex over some data.
-///
-/// This is not a safe primitive to use, it is unaware of the libgreen
-/// scheduler, as well as being easily susceptible to misuse due to the usage of
-/// the inner NativeMutex.
-///
-/// > **Note**: This type is not recommended for general use. The mutex provided
-/// >           as part of `libsync` should almost always be favored.
-pub struct Exclusive<T> {
-    lock: mutex::NativeMutex,
-    data: UnsafeCell<T>,
-}
-
-unsafe impl<T:Send> Send for Exclusive<T> { }
-
-unsafe impl<T:Send> Sync for Exclusive<T> { }
-
-/// An RAII guard returned via `lock`
-pub struct ExclusiveGuard<'a, T:'a> {
-    // FIXME #12808: strange name to try to avoid interfering with
-    // field accesses of the contained type via Deref
-    _data: &'a mut T,
-    _guard: mutex::LockGuard<'a>,
-}
-
-impl<T: Send> Exclusive<T> {
-    /// Creates a new `Exclusive` which will protect the data provided.
-    pub fn new(user_data: T) -> Exclusive<T> {
-        Exclusive {
-            lock: unsafe { mutex::NativeMutex::new() },
-            data: UnsafeCell::new(user_data),
-        }
-    }
-
-    /// Acquires this lock, returning a guard which the data is accessed through
-    /// and from which that lock will be unlocked.
-    ///
-    /// This method is unsafe due to many of the same reasons that the
-    /// NativeMutex itself is unsafe.
-    pub unsafe fn lock<'a>(&'a self) -> ExclusiveGuard<'a, T> {
-        let guard = self.lock.lock();
-        let data = &mut *self.data.get();
-
-        ExclusiveGuard {
-            _data: data,
-            _guard: guard,
-        }
-    }
-}
-
-impl<'a, T: Send> ExclusiveGuard<'a, T> {
-    // The unsafety here should be ok because our loan guarantees that the lock
-    // itself is not moving
-    pub fn signal(&self) {
-        unsafe { self._guard.signal() }
-    }
-    pub fn wait(&self) {
-        unsafe { self._guard.wait() }
-    }
-}
-
-impl<'a, T: Send> Deref<T> for ExclusiveGuard<'a, T> {
-    fn deref(&self) -> &T { &*self._data }
-}
-impl<'a, T: Send> DerefMut<T> for ExclusiveGuard<'a, T> {
-    fn deref_mut(&mut self) -> &mut T { &mut *self._data }
-}
-
-#[cfg(test)]
-mod tests {
-    use prelude::*;
-    use sync::Arc;
-    use super::Exclusive;
-    use task;
-
-    #[test]
-    fn exclusive_new_arc() {
-        unsafe {
-            let mut futures = Vec::new();
-
-            let num_tasks = 10;
-            let count = 10;
-
-            let total = Arc::new(Exclusive::new(box 0));
-
-            for _ in range(0u, num_tasks) {
-                let total = total.clone();
-                let (tx, rx) = channel();
-                futures.push(rx);
-
-                task::spawn(move || {
-                    for _ in range(0u, count) {
-                        **total.lock() += 1;
-                    }
-                    tx.send(());
-                });
-            };
-
-            for f in futures.iter_mut() { f.recv() }
-
-            assert_eq!(**total.lock(), num_tasks * count);
-        }
-    }
-}
index e0c512706e6a96b5fcdd5260748606cabd7ccecc..a6063d0b609b70d09f3f89fe88253ceb07724bd0 100644 (file)
@@ -84,15 +84,15 @@ struct Exception {
 // For more information, see below.
 const MAX_CALLBACKS: uint = 16;
 static CALLBACKS: [atomic::AtomicUint; MAX_CALLBACKS] =
-        [atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
-         atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
-         atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
-         atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
-         atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
-         atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
-         atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
-         atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT];
-static CALLBACK_CNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+        [atomic::ATOMIC_UINT_INIT, atomic::ATOMIC_UINT_INIT,
+         atomic::ATOMIC_UINT_INIT, atomic::ATOMIC_UINT_INIT,
+         atomic::ATOMIC_UINT_INIT, atomic::ATOMIC_UINT_INIT,
+         atomic::ATOMIC_UINT_INIT, atomic::ATOMIC_UINT_INIT,
+         atomic::ATOMIC_UINT_INIT, atomic::ATOMIC_UINT_INIT,
+         atomic::ATOMIC_UINT_INIT, atomic::ATOMIC_UINT_INIT,
+         atomic::ATOMIC_UINT_INIT, atomic::ATOMIC_UINT_INIT,
+         atomic::ATOMIC_UINT_INIT, atomic::ATOMIC_UINT_INIT];
+static CALLBACK_CNT: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT;
 
 thread_local! { static PANICKING: Cell<bool> = Cell::new(false) }
 
@@ -544,7 +544,7 @@ fn begin_unwind_inner(msg: Box<Any + Send>, file_line: &(&'static str, uint)) ->
     // Make sure the default failure handler is registered before we look at the
     // callbacks.
     static INIT: Once = ONCE_INIT;
-    INIT.doit(|| unsafe { register(failure::on_fail); });
+    INIT.call_once(|| unsafe { register(failure::on_fail); });
 
     // First, invoke call the user-defined callbacks triggered on thread panic.
     //
index fee86e33455d40c086e96c835bc0c675eca5537f..d66d8d52be9fad3fdc00ebd19e19c462647778b8 100644 (file)
@@ -47,7 +47,7 @@ pub fn limit_thread_creation_due_to_osx_and_valgrind() -> bool {
 }
 
 pub fn min_stack() -> uint {
-    static MIN: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+    static MIN: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT;
     match MIN.load(atomic::SeqCst) {
         0 => {}
         n => return n - 1,
index 18c917aca8a4aba2102adb4f7785fadee4f3786d..71eae8ac8afa2533e286f0d2d0c2d85bf0b0cd8b 100644 (file)
 //! Keep a global count of live tasks:
 //!
 //! ```
-//! use std::sync::atomic::{AtomicUint, SeqCst, INIT_ATOMIC_UINT};
+//! use std::sync::atomic::{AtomicUint, SeqCst, ATOMIC_UINT_INIT};
 //!
-//! static GLOBAL_TASK_COUNT: AtomicUint = INIT_ATOMIC_UINT;
+//! static GLOBAL_TASK_COUNT: AtomicUint = ATOMIC_UINT_INIT;
 //!
 //! let old_task_count = GLOBAL_TASK_COUNT.fetch_add(1, SeqCst);
 //! println!("live tasks: {}", old_task_count + 1);
 //! ```
 
-#![allow(deprecated)]
+#![stable]
 
 use alloc::boxed::Box;
 use core::mem;
 
 pub use core::atomic::{AtomicBool, AtomicInt, AtomicUint, AtomicPtr};
 pub use core::atomic::{INIT_ATOMIC_BOOL, INIT_ATOMIC_INT, INIT_ATOMIC_UINT};
+pub use core::atomic::{ATOMIC_BOOL_INIT, ATOMIC_INT_INIT, ATOMIC_UINT_INIT};
 pub use core::atomic::fence;
 pub use core::atomic::Ordering::{mod, Relaxed, Release, Acquire, AcqRel, SeqCst};
 
@@ -116,6 +117,7 @@ pub struct AtomicOption<T> {
     p: AtomicUint,
 }
 
+#[allow(deprecated)]
 impl<T: Send> AtomicOption<T> {
     /// Create a new `AtomicOption`
     pub fn new(p: Box<T>) -> AtomicOption<T> {
index 4091f0df39597d2b7fc683f257baf197574e4877..6dc37cdadbe1a14f4328ed68af1a9aaf7e3201a9 100644 (file)
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use kinds::{Send, Sync};
 use sync::{Mutex, Condvar};
 
 /// A barrier enables multiple tasks to synchronize the beginning
 ///     }).detach();
 /// }
 /// ```
+#[stable]
 pub struct Barrier {
     lock: Mutex<BarrierState>,
     cvar: Condvar,
     num_threads: uint,
 }
 
-unsafe impl Send for Barrier {}
-unsafe impl Sync for Barrier {}
-
 // The inner state of a double barrier
 struct BarrierState {
     count: uint,
     generation_id: uint,
 }
 
-unsafe impl Send for BarrierState {}
-unsafe impl Sync for BarrierState {}
+/// A result returned from wait.
+///
+/// Currently this opaque structure only has one method, `.is_leader()`. Only
+/// one thread will receive a result that will return `true` from this function.
+#[allow(missing_copy_implementations)]
+pub struct BarrierWaitResult(bool);
 
 impl Barrier {
     /// Create a new barrier that can block a given number of threads.
     ///
     /// A barrier will block `n`-1 threads which call `wait` and then wake up
     /// all threads at once when the `n`th thread calls `wait`.
+    #[stable]
     pub fn new(n: uint) -> Barrier {
         Barrier {
             lock: Mutex::new(BarrierState {
@@ -68,7 +70,13 @@ pub fn new(n: uint) -> Barrier {
     ///
     /// Barriers are re-usable after all threads have rendezvoused once, and can
     /// be used continuously.
-    pub fn wait(&self) {
+    ///
+    /// A single (arbitrary) thread will receive a `BarrierWaitResult` that
+    /// returns `true` from `is_leader` when returning from this function, and
+    /// all other threads will receive a result that will return `false` from
+    /// `is_leader`
+    #[stable]
+    pub fn wait(&self) -> BarrierWaitResult {
         let mut lock = self.lock.lock().unwrap();
         let local_gen = lock.generation_id;
         lock.count += 1;
@@ -79,32 +87,44 @@ pub fn wait(&self) {
                   lock.count < self.num_threads {
                 lock = self.cvar.wait(lock).unwrap();
             }
+            BarrierWaitResult(false)
         } else {
             lock.count = 0;
             lock.generation_id += 1;
             self.cvar.notify_all();
+            BarrierWaitResult(true)
         }
     }
 }
 
+impl BarrierWaitResult {
+    /// Return whether this thread from `wait` is the "leader thread".
+    ///
+    /// Only one thread will have `true` returned from their result, all other
+    /// threads will have `false` returned.
+    #[stable]
+    pub fn is_leader(&self) -> bool { self.0 }
+}
+
 #[cfg(test)]
 mod tests {
     use prelude::*;
 
-    use sync::{Arc, Barrier};
     use comm::Empty;
+    use sync::{Arc, Barrier};
 
     #[test]
     fn test_barrier() {
-        let barrier = Arc::new(Barrier::new(10));
+        const N: uint = 10;
+
+        let barrier = Arc::new(Barrier::new(N));
         let (tx, rx) = channel();
 
-        for _ in range(0u, 9) {
+        for _ in range(0u, N - 1) {
             let c = barrier.clone();
             let tx = tx.clone();
             spawn(move|| {
-                c.wait();
-                tx.send(true);
+                tx.send(c.wait().is_leader());
             });
         }
 
@@ -115,10 +135,15 @@ fn test_barrier() {
             _ => false,
         });
 
-        barrier.wait();
+        let mut leader_found = barrier.wait().is_leader();
+
         // Now, the barrier is cleared and we should get data.
-        for _ in range(0u, 9) {
-            rx.recv();
+        for _ in range(0u, N - 1) {
+            if rx.recv() {
+                assert!(!leader_found);
+                leader_found = true;
+            }
         }
+        assert!(leader_found);
     }
 }
index 15faf5be258f594816a289fda4d0e9f9fe8104a1..79a7af7454d6a256f0efc3efd6a041278235d56e 100644 (file)
@@ -88,7 +88,7 @@ unsafe impl Sync for StaticCondvar {}
 #[unstable = "may be merged with Condvar in the future"]
 pub const CONDVAR_INIT: StaticCondvar = StaticCondvar {
     inner: sys::CONDVAR_INIT,
-    mutex: atomic::INIT_ATOMIC_UINT,
+    mutex: atomic::ATOMIC_UINT_INIT,
 };
 
 impl Condvar {
index 51899a87a325d72d05aff960e81f20817b041aec..c952d13ef043da1bb0ea210e92fd7fa7c0a2e778 100644 (file)
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! A type representing values that may be computed concurrently and operations for working with
-//! them.
+//! A type representing values that may be computed concurrently and operations
+//! for working with them.
 //!
 //! # Example
 //!
@@ -23,6 +23,9 @@
 //! ```
 
 #![allow(missing_docs)]
+#![unstable = "futures as-is have yet to be deeply reevaluated with recent \
+               core changes to Rust's synchronization story, and will likely \
+               become stable in the future but are unstable until that time"]
 
 use core::prelude::*;
 use core::mem::replace;
index 092acc7ff25698fc1e33b0a0ed362add32665856..de455d8a6c6f5b0fe7bddd2baa7ac53c430a0198 100644 (file)
@@ -26,7 +26,7 @@
 pub use self::condvar::{Condvar, StaticCondvar, CONDVAR_INIT};
 pub use self::once::{Once, ONCE_INIT};
 pub use self::semaphore::{Semaphore, SemaphoreGuard};
-pub use self::barrier::Barrier;
+pub use self::barrier::{Barrier, BarrierWaitResult};
 pub use self::poison::{PoisonError, TryLockError, TryLockResult, LockResult};
 
 pub use self::future::Future;
index 4d9fbb5990840af8ce3ab716a962b3e66c20912e..e9e3e79812abc4c08dd62f4754ea3840479660e6 100644 (file)
 ///
 /// static START: Once = ONCE_INIT;
 ///
-/// START.doit(|| {
+/// START.call_once(|| {
 ///     // run initialization here
 /// });
 /// ```
+#[stable]
 pub struct Once {
     mutex: StaticMutex,
     cnt: atomic::AtomicInt,
@@ -45,23 +46,25 @@ pub struct Once {
 unsafe impl Sync for Once {}
 
 /// Initialization value for static `Once` values.
+#[stable]
 pub const ONCE_INIT: Once = Once {
     mutex: MUTEX_INIT,
-    cnt: atomic::INIT_ATOMIC_INT,
-    lock_cnt: atomic::INIT_ATOMIC_INT,
+    cnt: atomic::ATOMIC_INT_INIT,
+    lock_cnt: atomic::ATOMIC_INT_INIT,
 };
 
 impl Once {
     /// Perform an initialization routine once and only once. The given closure
-    /// will be executed if this is the first time `doit` has been called, and
-    /// otherwise the routine will *not* be invoked.
+    /// will be executed if this is the first time `call_once` has been called,
+    /// and otherwise the routine will *not* be invoked.
     ///
     /// This method will block the calling task if another initialization
     /// routine is currently running.
     ///
     /// When this function returns, it is guaranteed that some initialization
     /// has run and completed (it may not be the closure specified).
-    pub fn doit<F>(&'static self, f: F) where F: FnOnce() {
+    #[stable]
+    pub fn call_once<F>(&'static self, f: F) where F: FnOnce() {
         // Optimize common path: load is much cheaper than fetch_add.
         if self.cnt.load(atomic::SeqCst) < 0 {
             return
@@ -91,13 +94,13 @@ pub fn doit<F>(&'static self, f: F) where F: FnOnce() {
         //
         // It is crucial that the negative value is swapped in *after* the
         // initialization routine has completed because otherwise new threads
-        // calling `doit` will return immediately before the initialization has
-        // completed.
+        // calling `call_once` will return immediately before the initialization
+        // has completed.
 
         let prev = self.cnt.fetch_add(1, atomic::SeqCst);
         if prev < 0 {
             // Make sure we never overflow, we'll never have int::MIN
-            // simultaneous calls to `doit` to make this value go back to 0
+            // simultaneous calls to `call_once` to make this value go back to 0
             self.cnt.store(int::MIN, atomic::SeqCst);
             return
         }
@@ -118,6 +121,10 @@ pub fn doit<F>(&'static self, f: F) where F: FnOnce() {
             unsafe { self.mutex.destroy() }
         }
     }
+
+    /// Deprecated
+    #[deprecated = "renamed to `call_once`"]
+    pub fn doit<F>(&'static self, f: F) where F: FnOnce() { self.call_once(f) }
 }
 
 #[cfg(test)]
@@ -131,9 +138,9 @@ mod test {
     fn smoke_once() {
         static O: Once = ONCE_INIT;
         let mut a = 0i;
-        O.doit(|| a += 1);
+        O.call_once(|| a += 1);
         assert_eq!(a, 1);
-        O.doit(|| a += 1);
+        O.call_once(|| a += 1);
         assert_eq!(a, 1);
     }
 
@@ -148,7 +155,7 @@ fn stampede_once() {
             spawn(move|| {
                 for _ in range(0u, 4) { Thread::yield_now() }
                 unsafe {
-                    O.doit(|| {
+                    O.call_once(|| {
                         assert!(!run);
                         run = true;
                     });
@@ -159,7 +166,7 @@ fn stampede_once() {
         }
 
         unsafe {
-            O.doit(|| {
+            O.call_once(|| {
                 assert!(!run);
                 run = true;
             });
index e3b683a6ccb380786588fd57930197e9e2efb3c5..bd86e5d0ed25dbe1b9a40ca611b5a21de34be1bc 100644 (file)
@@ -8,6 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![unstable = "the interaction between semaphores and the acquisition/release \
+               of resources is currently unclear"]
+
 use ops::Drop;
 use sync::{Mutex, Condvar};
 
index ee534f6cdde3ecf135ad0e2590d597448cd88f1d..632ad49e952078f6d85f8e357564b8e8c7e91b34 100644 (file)
 
 //! Abstraction of a thread pool for basic parallelism.
 
+#![unstable = "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 `std::sync` is questionable with \
+               respect to the jobs of other primitives"]
+
 use core::prelude::*;
 
 use thread::Thread;
index fe7a7d8d0371688540bd19b327340f7a5b268afe..597790af83c9600efef1d3e6c1777dfba9b11a55 100644 (file)
@@ -137,7 +137,7 @@ pub struct Key {
 ///
 /// This value allows specific configuration of the destructor for a TLS key.
 pub const INIT_INNER: StaticKeyInner = StaticKeyInner {
-    key: atomic::INIT_ATOMIC_UINT,
+    key: atomic::ATOMIC_UINT_INIT,
 };
 
 static INIT_KEYS: Once = ONCE_INIT;
index 595191db3b2829b91910524ad23961896a79e4cf..0ccf130af6ea7064e763fd6bca1a462034365868 100644 (file)
@@ -18,7 +18,7 @@
 use libc::{mod, c_int, c_char, c_void};
 use path::BytesContainer;
 use ptr;
-use sync::atomic::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
+use sync::atomic::{AtomicInt, SeqCst};
 use sys::fs::FileDesc;
 use os;
 
index 868b460aa5ed3897e807bc667aaf05babd764949..1e1b95ee96c480c41743d07f77cb262a3f3f3b1c 100644 (file)
@@ -8,13 +8,14 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use prelude::*;
+
 use alloc::arc::Arc;
 use libc;
 use c_str::CString;
 use mem;
 use sync::{atomic, Mutex};
 use io::{mod, IoResult, IoError};
-use prelude::*;
 
 use sys::{mod, timer, retry, c, set_nonblocking, wouldblock};
 use sys::fs::{fd_t, FileDesc};
@@ -117,9 +118,6 @@ pub struct UnixStream {
     write_deadline: u64,
 }
 
-unsafe impl Send for UnixStream {}
-unsafe impl Sync for UnixStream {}
-
 impl UnixStream {
     pub fn connect(addr: &CString,
                    timeout: Option<u64>) -> IoResult<UnixStream> {
@@ -218,6 +216,7 @@ pub struct UnixListener {
     path: CString,
 }
 
+// we currently own the CString, so these impls should be safe
 unsafe impl Send for UnixListener {}
 unsafe impl Sync for UnixListener {}
 
@@ -265,9 +264,6 @@ struct AcceptorInner {
     closed: atomic::AtomicBool,
 }
 
-unsafe impl Send for AcceptorInner {}
-unsafe impl Sync for AcceptorInner {}
-
 impl UnixAcceptor {
     pub fn fd(&self) -> fd_t { self.inner.listener.fd() }
 
index c0ef89666c0f59b16885ee4a1ce6369ace8af752..25216c35b6580dffd62e7189c8e7166dc5199abb 100644 (file)
@@ -211,7 +211,7 @@ pub fn new() -> IoResult<Timer> {
         // instead of ()
         HELPER.boot(|| {}, helper);
 
-        static ID: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+        static ID: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT;
         let id = ID.fetch_add(1, atomic::Relaxed);
         Ok(Timer {
             id: id,
index 57c284ed6a32699fc9ef11b1a09c196957e8337c..88313d661737fe974f4ee7b775a1a34d53711e98 100644 (file)
@@ -171,7 +171,7 @@ pub fn init_net() {
     unsafe {
         static START: Once = ONCE_INIT;
 
-        START.doit(|| {
+        START.call_once(|| {
             let mut data: c::WSADATA = mem::zeroed();
             let ret = c::WSAStartup(0x202, // version 2.2
                                     &mut data);
index 3ac7c09154e352e10d1514a618f7d3ccb4a784e3..5f65b429d869e628e7db90874aa9451f032f5078 100644 (file)
@@ -20,7 +20,7 @@
 
 pub struct Mutex { inner: atomic::AtomicUint }
 
-pub const MUTEX_INIT: Mutex = Mutex { inner: atomic::INIT_ATOMIC_UINT };
+pub const MUTEX_INIT: Mutex = Mutex { inner: atomic::ATOMIC_UINT_INIT };
 
 unsafe impl Sync for Mutex {}
 
index 7bc15798a4f2e6c4b0c7363dddc23e38e639e1e1..d6c94f27a8baf9462dea4a451861ad329956d37b 100644 (file)
@@ -45,7 +45,7 @@ fn os_precise_time_ns() -> u64 {
                                                                                    denom: 0 };
         static ONCE: sync::Once = sync::ONCE_INIT;
         unsafe {
-            ONCE.doit(|| {
+            ONCE.call_once(|| {
                 imp::mach_timebase_info(&mut TIMEBASE);
             });
             let time = imp::mach_absolute_time();
index 87a00334c478f914ecb668833ebd9ecafb1ba877..2cf4c15606916d2c4a9a66f28bb9bc787062c452 100644 (file)
@@ -198,7 +198,7 @@ fn os_precise_time_ns() -> u64 {
                                                                                    denom: 0 };
         static ONCE: std::sync::Once = std::sync::ONCE_INIT;
         unsafe {
-            ONCE.doit(|| {
+            ONCE.call_once(|| {
                 imp::mach_timebase_info(&mut TIMEBASE);
             });
             let time = imp::mach_absolute_time();
index f0b431b1db932c9226a70efae1972c450b919af9..689610d799ec065d979858c998df04ce60a473d5 100644 (file)
 use std::sync::atomic;
 
 pub const C1: uint = 1;
-pub const C2: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+pub const C2: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT;
 pub const C3: fn() = foo;
 pub const C4: uint = C1 * C1 + C1 / C1;
 pub const C5: &'static uint = &C4;
 
 pub static S1: uint = 3;
-pub static S2: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+pub static S2: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT;
 
 fn foo() {}
index 0b16e8011e8323975d96ef792b8070b18aff1610..236e1cbb217352385246cecd807bdc73b65368b5 100644 (file)
@@ -41,7 +41,7 @@
 extern crate arena;
 
 use std::iter::range_step;
-use std::sync::Future;
+use std::thread::Thread;
 use arena::TypedArena;
 
 enum Tree<'a> {
@@ -95,7 +95,7 @@ fn main() {
     let mut messages = range_step(min_depth, max_depth + 1, 2).map(|depth| {
             use std::num::Int;
             let iterations = 2i.pow((max_depth - depth + min_depth) as uint);
-            Future::spawn(move|| {
+            Thread::spawn(move|| {
                 let mut chk = 0;
                 for i in range(1, iterations + 1) {
                     let arena = TypedArena::new();
@@ -106,10 +106,10 @@ fn main() {
                 format!("{}\t trees of depth {}\t check: {}",
                         iterations * 2, depth, chk)
             })
-        }).collect::<Vec<Future<String>>>();
+        }).collect::<Vec<_>>();
 
-    for message in messages.iter_mut() {
-        println!("{}", *message.get_ref());
+    for message in messages.into_iter() {
+        println!("{}", message.join().ok().unwrap());
     }
 
     println!("long lived tree of depth {}\t check: {}",
index ef38f5ef74341a841d8ae2a7d4bef56617ae317a..8e594b861803f57be4811fd10c9353577598231e 100644 (file)
@@ -41,7 +41,7 @@
 #![feature(slicing_syntax)]
 
 use std::{cmp, iter, mem};
-use std::sync::Future;
+use std::thread::Thread;
 
 fn rotate(x: &mut [i32]) {
     let mut prev = x[0];
@@ -168,15 +168,15 @@ fn fannkuch(n: i32) -> (i32, i32) {
     for (i, j) in range(0, N).zip(iter::count(0, k)) {
         let max = cmp::min(j+k, perm.max());
 
-        futures.push(Future::spawn(move|| {
+        futures.push(Thread::spawn(move|| {
             work(perm, j as uint, max as uint)
         }))
     }
 
     let mut checksum = 0;
     let mut maxflips = 0;
-    for fut in futures.iter_mut() {
-        let (cs, mf) = fut.get();
+    for fut in futures.into_iter() {
+        let (cs, mf) = fut.join().ok().unwrap();
         checksum += cs;
         maxflips = cmp::max(maxflips, mf);
     }
index c0122b8a2a97ac8735462d26b3b1b8b801124fe9..501187ca9e5435257bb62a0ee9ba426146d68b9f 100644 (file)
 use std::ptr;
 
 fn main() {
-    let x = INIT_ATOMIC_BOOL;
+    let x = ATOMIC_BOOL_INIT;
     let x = *&x; //~ ERROR: cannot move out of dereference
-    let x = INIT_ATOMIC_INT;
+    let x = ATOMIC_INT_INIT;
     let x = *&x; //~ ERROR: cannot move out of dereference
-    let x = INIT_ATOMIC_UINT;
+    let x = ATOMIC_UINT_INIT;
     let x = *&x; //~ ERROR: cannot move out of dereference
     let x: AtomicPtr<uint> = AtomicPtr::new(ptr::null_mut());
     let x = *&x; //~ ERROR: cannot move out of dereference
index 90a102222ba172c31662dc976feaa36f55aee2bb..10ad0f620e9f3076442ba870abae2fb60a0ac573 100644 (file)
@@ -15,7 +15,7 @@
 use std::sync::atomic;
 
 const C1: uint = 1;
-const C2: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+const C2: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT;
 const C3: fn() = foo;
 const C4: uint = C1 * C1 + C1 / C1;
 const C5: &'static uint = &C4;
@@ -25,7 +25,7 @@
 };
 
 static S1: uint = 3;
-static S2: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+static S2: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT;
 
 mod test {
     static A: uint = 4;
index 6ff1cffb4a42f448bf9fda4a3d7cc8e98fdbf4de..c5f5cd2c3aab58dde727d58fc8157b5642235e53 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use std::task;
-use std::sync::atomic::{AtomicUint, INIT_ATOMIC_UINT, Relaxed};
+use std::sync::atomic::{AtomicUint, ATOMIC_UINT_INIT, Relaxed};
 use std::rand::{thread_rng, Rng, Rand};
 
 const REPEATS: uint = 5;
 static drop_counts: [AtomicUint;  MAX_LEN] =
     // FIXME #5244: AtomicUint is not Copy.
     [
-        INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
-        INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
-        INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
-        INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
+        ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
+        ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
+        ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
+        ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
 
-        INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
-        INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
-        INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
-        INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
+        ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
+        ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
+        ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
+        ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
      ];
 
-static creation_count: AtomicUint = INIT_ATOMIC_UINT;
+static creation_count: AtomicUint = ATOMIC_UINT_INIT;
 
 #[deriving(Clone, PartialEq, PartialOrd, Eq, Ord)]
 struct DropCounter { x: uint, creation_id: uint }