Skip to content

Commit 87ea0e7

Browse files
author
James Miller
committed
---
yaml --- r: 62709 b: refs/heads/snap-stage3 c: df1814b h: refs/heads/master i: 62707: 8e8c4cb v: v3
1 parent d5abe8b commit 87ea0e7

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 30b471bf23f171645fcb61b2c677c6d12061f05b
4+
refs/heads/snap-stage3: df1814ba089e8b86bd7e191afa99c7bd10e05d4f
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libstd/unstable/atomics.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010

1111
/*!
1212
* Atomic types
13+
*
14+
* Basic atomic types supporting atomic operations. Each method takes an `Ordering` which
15+
* represents the strength of the memory barrier for that operation. These orderings are the same
16+
* as C++11 atomic orderings [http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync]
17+
*
18+
* All atomic types are a single word in size.
1319
*/
1420

1521
use unstable::intrinsics;
@@ -18,26 +24,44 @@ use option::{Option,Some,None};
1824
use libc::c_void;
1925
use ops::Drop;
2026

27+
/**
28+
* A simple atomic flag, that can be set and cleared. The most basic atomic type.
29+
*/
2130
pub struct AtomicFlag {
2231
priv v: int
2332
}
2433

34+
/**
35+
* An atomic boolean type.
36+
*/
2537
pub struct AtomicBool {
2638
priv v: uint
2739
}
2840

41+
/**
42+
* A signed atomic integer type, supporting basic atomic aritmetic operations
43+
*/
2944
pub struct AtomicInt {
3045
priv v: int
3146
}
3247

48+
/**
49+
* An unsigned atomic integer type, supporting basic atomic aritmetic operations
50+
*/
3351
pub struct AtomicUint {
3452
priv v: uint
3553
}
3654

55+
/**
56+
* An unsafe atomic pointer. Only supports basic atomic operations
57+
*/
3758
pub struct AtomicPtr<T> {
3859
priv p: *mut T
3960
}
4061

62+
/**
63+
* An owned atomic pointer. Ensures that only a single reference to the data is held at any time.
64+
*/
4165
pub struct AtomicOption<T> {
4266
priv p: *mut c_void
4367
}
@@ -63,11 +87,11 @@ impl AtomicFlag {
6387
unsafe {atomic_store(&mut self.v, 0, order)}
6488
}
6589

66-
#[inline(always)]
6790
/**
6891
* Sets the flag if it was previously unset, returns the previous value of the
6992
* flag.
7093
*/
94+
#[inline(always)]
7195
fn test_and_set(&mut self, order: Ordering) -> bool {
7296
unsafe {atomic_compare_and_swap(&mut self.v, 0, 1, order) > 0}
7397
}

0 commit comments

Comments
 (0)