Skip to content

Commit cf2b00d

Browse files
committed
auto merge of #6941 : Thiez/rust/pub_atomics, r=thestinger
As the title suggests, this marks all the fns on the impls on the atomic types in std::unstable::atomics as pub, which makes them significantly more usable (they are rather unusable otherwise). r?
2 parents c75c11a + 979b037 commit cf2b00d

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

src/libstd/unstable/atomics.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ pub enum Ordering {
7575

7676
impl AtomicFlag {
7777

78-
fn new() -> AtomicFlag {
78+
pub fn new() -> AtomicFlag {
7979
AtomicFlag { v: 0 }
8080
}
8181

8282
/**
8383
* Clears the atomic flag
8484
*/
8585
#[inline(always)]
86-
fn clear(&mut self, order: Ordering) {
86+
pub fn clear(&mut self, order: Ordering) {
8787
unsafe {atomic_store(&mut self.v, 0, order)}
8888
}
8989

@@ -92,37 +92,37 @@ impl AtomicFlag {
9292
* flag.
9393
*/
9494
#[inline(always)]
95-
fn test_and_set(&mut self, order: Ordering) -> bool {
95+
pub fn test_and_set(&mut self, order: Ordering) -> bool {
9696
unsafe {atomic_compare_and_swap(&mut self.v, 0, 1, order) > 0}
9797
}
9898
}
9999

100100
impl AtomicBool {
101-
fn new(v: bool) -> AtomicBool {
101+
pub fn new(v: bool) -> AtomicBool {
102102
AtomicBool { v: if v { 1 } else { 0 } }
103103
}
104104

105105
#[inline(always)]
106-
fn load(&self, order: Ordering) -> bool {
106+
pub fn load(&self, order: Ordering) -> bool {
107107
unsafe { atomic_load(&self.v, order) > 0 }
108108
}
109109

110110
#[inline(always)]
111-
fn store(&mut self, val: bool, order: Ordering) {
111+
pub fn store(&mut self, val: bool, order: Ordering) {
112112
let val = if val { 1 } else { 0 };
113113

114114
unsafe { atomic_store(&mut self.v, val, order); }
115115
}
116116

117117
#[inline(always)]
118-
fn swap(&mut self, val: bool, order: Ordering) -> bool {
118+
pub fn swap(&mut self, val: bool, order: Ordering) -> bool {
119119
let val = if val { 1 } else { 0 };
120120

121121
unsafe { atomic_swap(&mut self.v, val, order) > 0}
122122
}
123123

124124
#[inline(always)]
125-
fn compare_and_swap(&mut self, old: bool, new: bool, order: Ordering) -> bool {
125+
pub fn compare_and_swap(&mut self, old: bool, new: bool, order: Ordering) -> bool {
126126
let old = if old { 1 } else { 0 };
127127
let new = if new { 1 } else { 0 };
128128

@@ -131,113 +131,113 @@ impl AtomicBool {
131131
}
132132

133133
impl AtomicInt {
134-
fn new(v: int) -> AtomicInt {
134+
pub fn new(v: int) -> AtomicInt {
135135
AtomicInt { v:v }
136136
}
137137

138138
#[inline(always)]
139-
fn load(&self, order: Ordering) -> int {
139+
pub fn load(&self, order: Ordering) -> int {
140140
unsafe { atomic_load(&self.v, order) }
141141
}
142142

143143
#[inline(always)]
144-
fn store(&mut self, val: int, order: Ordering) {
144+
pub fn store(&mut self, val: int, order: Ordering) {
145145
unsafe { atomic_store(&mut self.v, val, order); }
146146
}
147147

148148
#[inline(always)]
149-
fn swap(&mut self, val: int, order: Ordering) -> int {
149+
pub fn swap(&mut self, val: int, order: Ordering) -> int {
150150
unsafe { atomic_swap(&mut self.v, val, order) }
151151
}
152152

153153
#[inline(always)]
154-
fn compare_and_swap(&mut self, old: int, new: int, order: Ordering) -> int {
154+
pub fn compare_and_swap(&mut self, old: int, new: int, order: Ordering) -> int {
155155
unsafe { atomic_compare_and_swap(&mut self.v, old, new, order) }
156156
}
157157

158158
#[inline(always)]
159-
fn fetch_add(&mut self, val: int, order: Ordering) -> int {
159+
pub fn fetch_add(&mut self, val: int, order: Ordering) -> int {
160160
unsafe { atomic_add(&mut self.v, val, order) }
161161
}
162162

163163
#[inline(always)]
164-
fn fetch_sub(&mut self, val: int, order: Ordering) -> int {
164+
pub fn fetch_sub(&mut self, val: int, order: Ordering) -> int {
165165
unsafe { atomic_sub(&mut self.v, val, order) }
166166
}
167167
}
168168

169169
impl AtomicUint {
170-
fn new(v: uint) -> AtomicUint {
170+
pub fn new(v: uint) -> AtomicUint {
171171
AtomicUint { v:v }
172172
}
173173

174174
#[inline(always)]
175-
fn load(&self, order: Ordering) -> uint {
175+
pub fn load(&self, order: Ordering) -> uint {
176176
unsafe { atomic_load(&self.v, order) }
177177
}
178178

179179
#[inline(always)]
180-
fn store(&mut self, val: uint, order: Ordering) {
180+
pub fn store(&mut self, val: uint, order: Ordering) {
181181
unsafe { atomic_store(&mut self.v, val, order); }
182182
}
183183

184184
#[inline(always)]
185-
fn swap(&mut self, val: uint, order: Ordering) -> uint {
185+
pub fn swap(&mut self, val: uint, order: Ordering) -> uint {
186186
unsafe { atomic_swap(&mut self.v, val, order) }
187187
}
188188

189189
#[inline(always)]
190-
fn compare_and_swap(&mut self, old: uint, new: uint, order: Ordering) -> uint {
190+
pub fn compare_and_swap(&mut self, old: uint, new: uint, order: Ordering) -> uint {
191191
unsafe { atomic_compare_and_swap(&mut self.v, old, new, order) }
192192
}
193193

194194
#[inline(always)]
195-
fn fetch_add(&mut self, val: uint, order: Ordering) -> uint {
195+
pub fn fetch_add(&mut self, val: uint, order: Ordering) -> uint {
196196
unsafe { atomic_add(&mut self.v, val, order) }
197197
}
198198

199199
#[inline(always)]
200-
fn fetch_sub(&mut self, val: uint, order: Ordering) -> uint {
200+
pub fn fetch_sub(&mut self, val: uint, order: Ordering) -> uint {
201201
unsafe { atomic_sub(&mut self.v, val, order) }
202202
}
203203
}
204204

205205
impl<T> AtomicPtr<T> {
206-
fn new(p: *mut T) -> AtomicPtr<T> {
206+
pub fn new(p: *mut T) -> AtomicPtr<T> {
207207
AtomicPtr { p:p }
208208
}
209209

210210
#[inline(always)]
211-
fn load(&self, order: Ordering) -> *mut T {
211+
pub fn load(&self, order: Ordering) -> *mut T {
212212
unsafe { atomic_load(&self.p, order) }
213213
}
214214

215215
#[inline(always)]
216-
fn store(&mut self, ptr: *mut T, order: Ordering) {
216+
pub fn store(&mut self, ptr: *mut T, order: Ordering) {
217217
unsafe { atomic_store(&mut self.p, ptr, order); }
218218
}
219219

220220
#[inline(always)]
221-
fn swap(&mut self, ptr: *mut T, order: Ordering) -> *mut T {
221+
pub fn swap(&mut self, ptr: *mut T, order: Ordering) -> *mut T {
222222
unsafe { atomic_swap(&mut self.p, ptr, order) }
223223
}
224224

225225
#[inline(always)]
226-
fn compare_and_swap(&mut self, old: *mut T, new: *mut T, order: Ordering) -> *mut T {
226+
pub fn compare_and_swap(&mut self, old: *mut T, new: *mut T, order: Ordering) -> *mut T {
227227
unsafe { atomic_compare_and_swap(&mut self.p, old, new, order) }
228228
}
229229
}
230230

231231
impl<T> AtomicOption<T> {
232-
fn new(p: ~T) -> AtomicOption<T> {
232+
pub fn new(p: ~T) -> AtomicOption<T> {
233233
unsafe {
234234
AtomicOption {
235235
p: cast::transmute(p)
236236
}
237237
}
238238
}
239239

240-
fn empty() -> AtomicOption<T> {
240+
pub fn empty() -> AtomicOption<T> {
241241
unsafe {
242242
AtomicOption {
243243
p: cast::transmute(0)
@@ -246,7 +246,7 @@ impl<T> AtomicOption<T> {
246246
}
247247

248248
#[inline(always)]
249-
fn swap(&mut self, val: ~T, order: Ordering) -> Option<~T> {
249+
pub fn swap(&mut self, val: ~T, order: Ordering) -> Option<~T> {
250250
unsafe {
251251
let val = cast::transmute(val);
252252

@@ -262,7 +262,7 @@ impl<T> AtomicOption<T> {
262262
}
263263

264264
#[inline(always)]
265-
fn take(&mut self, order: Ordering) -> Option<~T> {
265+
pub fn take(&mut self, order: Ordering) -> Option<~T> {
266266
unsafe {
267267
self.swap(cast::transmute(0), order)
268268
}

0 commit comments

Comments
 (0)