about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAaron Turon <aturon@mozilla.com>2014-08-04 15:42:36 -0700
committerAaron Turon <aturon@mozilla.com>2014-08-04 16:03:21 -0700
commit68bde0a07396efb415d61047c6b2a8183f47ef30 (patch)
tree2a0d63e3153abbe4f62f15d06ee72c94c7772b2d /src/libstd
parent9de20198aedb3c3419ee503755e04bcc198d3a94 (diff)
downloadrust-68bde0a07396efb415d61047c6b2a8183f47ef30.tar.gz
rust-68bde0a07396efb415d61047c6b2a8183f47ef30.zip
stabilize atomics (now atomic)
This commit stabilizes the `std::sync::atomics` module, renaming it to
`std::sync::atomic` to match library precedent elsewhere, and tightening
up behavior around incorrect memory ordering annotations.

The vast majority of the module is now `stable`. However, the
`AtomicOption` type has been deprecated, since it is essentially unused
and is not truly a primitive atomic type. It will eventually be replaced
by a higher-level abstraction like MVars.

Due to deprecations, this is a:

[breaking-change]
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/tempfile.rs6
-rw-r--r--src/libstd/io/test.rs2
-rw-r--r--src/libstd/os.rs2
-rw-r--r--src/libstd/rt/backtrace.rs8
-rw-r--r--src/libstd/rt/util.rs8
-rw-r--r--src/libstd/sync/mod.rs8
6 files changed, 20 insertions, 14 deletions
diff --git a/src/libstd/io/tempfile.rs b/src/libstd/io/tempfile.rs
index f580dfd80f0..1d53ed81437 100644
--- a/src/libstd/io/tempfile.rs
+++ b/src/libstd/io/tempfile.rs
@@ -19,7 +19,7 @@ use option::{Option, None, Some};
 use os;
 use path::{Path, GenericPath};
 use result::{Ok, Err};
-use sync::atomics;
+use sync::atomic;
 
 #[cfg(stage0)]
 use iter::Iterator; // NOTE(stage0): Remove after snapshot.
@@ -42,13 +42,13 @@ impl TempDir {
             return TempDir::new_in(&os::make_absolute(tmpdir), suffix);
         }
 
-        static mut CNT: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT;
+        static mut CNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
 
         for _ in range(0u, 1000) {
             let filename =
                 format!("rs-{}-{}-{}",
                         unsafe { libc::getpid() },
-                        unsafe { CNT.fetch_add(1, atomics::SeqCst) },
+                        unsafe { CNT.fetch_add(1, atomic::SeqCst) },
                         suffix);
             let p = tmpdir.join(filename);
             match fs::mkdir(&p, io::UserRWX) {
diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs
index 26e854d9d99..331cfa1a59e 100644
--- a/src/libstd/io/test.rs
+++ b/src/libstd/io/test.rs
@@ -16,7 +16,7 @@ use libc;
 use os;
 use prelude::*;
 use std::io::net::ip::*;
-use sync::atomics::{AtomicUint, INIT_ATOMIC_UINT, Relaxed};
+use sync::atomic::{AtomicUint, INIT_ATOMIC_UINT, Relaxed};
 
 macro_rules! iotest (
     { fn $name:ident() $b:block $(#[$a:meta])* } => (
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index dfa691d1823..6ba964441ee 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -48,7 +48,7 @@ use result::{Err, Ok, Result};
 use slice::{Vector, ImmutableVector, MutableVector, ImmutableEqVector};
 use str::{Str, StrSlice, StrAllocating};
 use string::String;
-use sync::atomics::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
+use sync::atomic::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
 use vec::Vec;
 
 #[cfg(unix)]
diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs
index 80493ebb4a9..6c02cc631f5 100644
--- a/src/libstd/rt/backtrace.rs
+++ b/src/libstd/rt/backtrace.rs
@@ -20,7 +20,7 @@ use option::{Some, None};
 use os;
 use result::{Ok, Err};
 use str::StrSlice;
-use sync::atomics;
+use sync::atomic;
 use unicode::char::UnicodeChar;
 
 pub use self::imp::write;
@@ -28,9 +28,9 @@ pub use self::imp::write;
 // 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 mut ENABLED: atomics::AtomicInt = atomics::INIT_ATOMIC_INT;
+    static mut ENABLED: atomic::AtomicInt = atomic::INIT_ATOMIC_INT;
     unsafe {
-        match ENABLED.load(atomics::SeqCst) {
+        match ENABLED.load(atomic::SeqCst) {
             1 => return false,
             2 => return true,
             _ => {}
@@ -41,7 +41,7 @@ pub fn log_enabled() -> bool {
         Some(..) => 2,
         None => 1,
     };
-    unsafe { ENABLED.store(val, atomics::SeqCst); }
+    unsafe { ENABLED.store(val, atomic::SeqCst); }
     val == 2
 }
 
diff --git a/src/libstd/rt/util.rs b/src/libstd/rt/util.rs
index fa30ddbcc48..ed24ed2a569 100644
--- a/src/libstd/rt/util.rs
+++ b/src/libstd/rt/util.rs
@@ -14,7 +14,7 @@ use libc::uintptr_t;
 use option::{Some, None, Option};
 use os;
 use str::Str;
-use sync::atomics;
+use sync::atomic;
 
 /// Dynamically inquire about whether we're running under V.
 /// You should usually not use this unless your test definitely
@@ -41,8 +41,8 @@ pub fn limit_thread_creation_due_to_osx_and_valgrind() -> bool {
 }
 
 pub fn min_stack() -> uint {
-    static mut MIN: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT;
-    match unsafe { MIN.load(atomics::SeqCst) } {
+    static mut MIN: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+    match unsafe { MIN.load(atomic::SeqCst) } {
         0 => {}
         n => return n - 1,
     }
@@ -50,7 +50,7 @@ pub fn min_stack() -> uint {
     let amt = amt.unwrap_or(2 * 1024 * 1024);
     // 0 is our sentinel value, so ensure that we'll never see 0 after
     // initialization has run
-    unsafe { MIN.store(amt + 1, atomics::SeqCst); }
+    unsafe { MIN.store(amt + 1, atomic::SeqCst); }
     return amt;
 }
 
diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs
index cc32818baa4..1d189f8d4bc 100644
--- a/src/libstd/sync/mod.rs
+++ b/src/libstd/sync/mod.rs
@@ -17,12 +17,18 @@
 
 #![experimental]
 
-pub use core_sync::{atomics, deque, mpmc_bounded_queue, mpsc_queue, spsc_queue};
+#[stable]
+pub use core_sync::atomic;
+
+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};
 
+#[deprecated = "use atomic instead"]
+pub use atomics = core_sync::atomic;
+
 pub use self::future::Future;
 pub use self::task_pool::TaskPool;