summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-11-07 17:36:17 -0800
committerBrian Anderson <banderson@mozilla.com>2013-11-07 18:37:56 -0800
commiteabdc8c960f971bd0ce72e50a5847f3bfedaa65f (patch)
tree5edcca091bef7ff0c24a075508a321ae4048e924 /src/libstd
parent03f30515f4c8ca91dc7ceba3628f6eb1b3259ac5 (diff)
downloadrust-eabdc8c960f971bd0ce72e50a5847f3bfedaa65f.tar.gz
rust-eabdc8c960f971bd0ce72e50a5847f3bfedaa65f.zip
std: Make atomic types non-copyable. Closes #8380
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/unstable/atomics.rs34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/libstd/unstable/atomics.rs b/src/libstd/unstable/atomics.rs
index e8835462a80..9aaccb3ebba 100644
--- a/src/libstd/unstable/atomics.rs
+++ b/src/libstd/unstable/atomics.rs
@@ -23,40 +23,46 @@ use cast;
 use option::{Option,Some,None};
 use libc::c_void;
 use ops::Drop;
+use util::NonCopyable;
 
 /**
  * A simple atomic flag, that can be set and cleared. The most basic atomic type.
  */
 pub struct AtomicFlag {
-    priv v: int
+    priv v: int,
+    priv nocopy: NonCopyable
 }
 
 /**
  * An atomic boolean type.
  */
 pub struct AtomicBool {
-    priv v: uint
+    priv v: uint,
+    priv nocopy: NonCopyable
 }
 
 /**
  * A signed atomic integer type, supporting basic atomic arithmetic operations
  */
 pub struct AtomicInt {
-    priv v: int
+    priv v: int,
+    priv nocopy: NonCopyable
 }
 
 /**
  * An unsigned atomic integer type, supporting basic atomic arithmetic operations
  */
 pub struct AtomicUint {
-    priv v: uint
+    priv v: uint,
+    priv nocopy: NonCopyable
 }
 
 /**
  * An unsafe atomic pointer. Only supports basic atomic operations
  */
 pub struct AtomicPtr<T> {
-    priv p: *mut T
+    priv p: *mut T,
+    priv nocopy: NonCopyable
 }
 
 /**
@@ -75,15 +81,15 @@ pub enum Ordering {
     SeqCst
 }
 
-pub static INIT_ATOMIC_FLAG : AtomicFlag = AtomicFlag { v: 0 };
-pub static INIT_ATOMIC_BOOL : AtomicBool = AtomicBool { v: 0 };
-pub static INIT_ATOMIC_INT  : AtomicInt  = AtomicInt  { v: 0 };
-pub static INIT_ATOMIC_UINT : AtomicUint = AtomicUint { v: 0 };
+pub static INIT_ATOMIC_FLAG : AtomicFlag = AtomicFlag { v: 0, nocopy: NonCopyable };
+pub static INIT_ATOMIC_BOOL : AtomicBool = AtomicBool { v: 0, nocopy: NonCopyable };
+pub static INIT_ATOMIC_INT  : AtomicInt  = AtomicInt  { v: 0, nocopy: NonCopyable };
+pub static INIT_ATOMIC_UINT : AtomicUint = AtomicUint { v: 0, nocopy: NonCopyable };
 
 impl AtomicFlag {
 
     pub fn new() -> AtomicFlag {
-        AtomicFlag { v: 0 }
+        AtomicFlag { v: 0, nocopy: NonCopyable }
     }
 
     /**
@@ -106,7 +112,7 @@ impl AtomicFlag {
 
 impl AtomicBool {
     pub fn new(v: bool) -> AtomicBool {
-        AtomicBool { v: if v { 1 } else { 0 } }
+        AtomicBool { v: if v { 1 } else { 0 }, nocopy: NonCopyable }
     }
 
     #[inline]
@@ -171,7 +177,7 @@ impl AtomicBool {
 
 impl AtomicInt {
     pub fn new(v: int) -> AtomicInt {
-        AtomicInt { v:v }
+        AtomicInt { v:v, nocopy: NonCopyable }
     }
 
     #[inline]
@@ -209,7 +215,7 @@ impl AtomicInt {
 
 impl AtomicUint {
     pub fn new(v: uint) -> AtomicUint {
-        AtomicUint { v:v }
+        AtomicUint { v:v, nocopy: NonCopyable }
     }
 
     #[inline]
@@ -247,7 +253,7 @@ impl AtomicUint {
 
 impl<T> AtomicPtr<T> {
     pub fn new(p: *mut T) -> AtomicPtr<T> {
-        AtomicPtr { p:p }
+        AtomicPtr { p:p, nocopy: NonCopyable }
     }
 
     #[inline]