@@ -23,40 +23,46 @@ use cast;
23
23
use option:: { Option , Some , None } ;
24
24
use libc:: c_void;
25
25
use ops:: Drop ;
26
+ use util:: NonCopyable ;
26
27
27
28
/**
28
29
* A simple atomic flag, that can be set and cleared. The most basic atomic type.
29
30
*/
30
31
pub struct AtomicFlag {
31
- priv v: int
32
+ priv v: int ,
33
+ priv nocopy : NonCopyable
32
34
}
33
35
34
36
/**
35
37
* An atomic boolean type.
36
38
*/
37
39
pub struct AtomicBool {
38
- priv v: uint
40
+ priv v: uint ,
41
+ priv nocopy : NonCopyable
39
42
}
40
43
41
44
/**
42
45
* A signed atomic integer type, supporting basic atomic arithmetic operations
43
46
*/
44
47
pub struct AtomicInt {
45
- priv v: int
48
+ priv v: int ,
49
+ priv nocopy : NonCopyable
46
50
}
47
51
48
52
/**
49
53
* An unsigned atomic integer type, supporting basic atomic arithmetic operations
50
54
*/
51
55
pub struct AtomicUint {
52
- priv v: uint
56
+ priv v: uint ,
57
+ priv nocopy : NonCopyable
53
58
}
54
59
55
60
/**
56
61
* An unsafe atomic pointer. Only supports basic atomic operations
57
62
*/
58
63
pub struct AtomicPtr < T > {
59
- priv p: * mut T
64
+ priv p: * mut T ,
65
+ priv nocopy : NonCopyable
60
66
}
61
67
62
68
/**
@@ -75,15 +81,15 @@ pub enum Ordering {
75
81
SeqCst
76
82
}
77
83
78
- pub static INIT_ATOMIC_FLAG : AtomicFlag = AtomicFlag { v : 0 } ;
79
- pub static INIT_ATOMIC_BOOL : AtomicBool = AtomicBool { v : 0 } ;
80
- pub static INIT_ATOMIC_INT : AtomicInt = AtomicInt { v : 0 } ;
81
- pub static INIT_ATOMIC_UINT : AtomicUint = AtomicUint { v : 0 } ;
84
+ pub static INIT_ATOMIC_FLAG : AtomicFlag = AtomicFlag { v : 0 , nocopy : NonCopyable } ;
85
+ pub static INIT_ATOMIC_BOOL : AtomicBool = AtomicBool { v : 0 , nocopy : NonCopyable } ;
86
+ pub static INIT_ATOMIC_INT : AtomicInt = AtomicInt { v : 0 , nocopy : NonCopyable } ;
87
+ pub static INIT_ATOMIC_UINT : AtomicUint = AtomicUint { v : 0 , nocopy : NonCopyable } ;
82
88
83
89
impl AtomicFlag {
84
90
85
91
pub fn new ( ) -> AtomicFlag {
86
- AtomicFlag { v : 0 }
92
+ AtomicFlag { v : 0 , nocopy : NonCopyable }
87
93
}
88
94
89
95
/**
@@ -106,7 +112,7 @@ impl AtomicFlag {
106
112
107
113
impl AtomicBool {
108
114
pub fn new ( v : bool ) -> AtomicBool {
109
- AtomicBool { v : if v { 1 } else { 0 } }
115
+ AtomicBool { v : if v { 1 } else { 0 } , nocopy : NonCopyable }
110
116
}
111
117
112
118
#[ inline]
@@ -171,7 +177,7 @@ impl AtomicBool {
171
177
172
178
impl AtomicInt {
173
179
pub fn new ( v : int ) -> AtomicInt {
174
- AtomicInt { v : v }
180
+ AtomicInt { v : v, nocopy : NonCopyable }
175
181
}
176
182
177
183
#[ inline]
@@ -209,7 +215,7 @@ impl AtomicInt {
209
215
210
216
impl AtomicUint {
211
217
pub fn new ( v : uint ) -> AtomicUint {
212
- AtomicUint { v : v }
218
+ AtomicUint { v : v, nocopy : NonCopyable }
213
219
}
214
220
215
221
#[ inline]
@@ -247,7 +253,7 @@ impl AtomicUint {
247
253
248
254
impl < T > AtomicPtr < T > {
249
255
pub fn new ( p : * mut T ) -> AtomicPtr < T > {
250
- AtomicPtr { p : p }
256
+ AtomicPtr { p : p, nocopy : NonCopyable }
251
257
}
252
258
253
259
#[ inline]
0 commit comments