Skip to content

Commit f3a7ec7

Browse files
committed
std: Second pass stabilization of sync
This pass performs a second pass of stabilization through the `std::sync` module, avoiding modules/types that are being handled in other PRs (e.g. mutexes, rwlocks, condvars, and channels). The following items are now stable * `sync::atomic` * `sync::atomic::ATOMIC_BOOL_INIT` (was `INIT_ATOMIC_BOOL`) * `sync::atomic::ATOMIC_INT_INIT` (was `INIT_ATOMIC_INT`) * `sync::atomic::ATOMIC_UINT_INIT` (was `INIT_ATOMIC_UINT`) * `sync::Once` * `sync::ONCE_INIT` * `sync::Once::call_once` (was `doit`) * C == `pthread_once(..)` * Boost == `call_once(..)` * Windows == `InitOnceExecuteOnce` * `sync::Barrier` * `sync::Barrier::new` * `sync::Barrier::wait` (now returns a `bool`) * `sync::Semaphore::new` * `sync::Semaphore::acquire` * `sync::Semaphore::release` The following items remain unstable * `sync::SemaphoreGuard` * `sync::Semaphore::access` - it's unclear how this relates to the poisoning story of mutexes. * `sync::TaskPool` - the semantics of a failing task and whether a thread is re-attached to a thread pool are somewhat unclear, and the utility of this type in `sync` is question with respect to the jobs of other primitives. This type will likely become stable or move out of the standard library over time. * `sync::Future` - futures as-is have yet to be deeply re-evaluated with the recent core changes to Rust's synchronization story, and will likely become stable in the future but are unstable until that time comes. [breaking-change]
1 parent cd61416 commit f3a7ec7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+168
-237
lines changed

src/doc/guide-tasks.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ getting the result later.
206206
The basic example below illustrates this.
207207

208208
```{rust,ignore}
209+
# #![allow(deprecated)]
209210
use std::sync::Future;
210211
211212
# fn main() {
@@ -233,6 +234,7 @@ Here is another example showing how futures allow you to background
233234
computations. The workload will be distributed on the available cores.
234235

235236
```{rust,ignore}
237+
# #![allow(deprecated)]
236238
# use std::num::Float;
237239
# use std::sync::Future;
238240
fn partial_sum(start: uint) -> f64 {

src/doc/guide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5312,6 +5312,7 @@ example, if you wish to compute some value in the background, `Future` is
53125312
a useful thing to use:
53135313
53145314
```{rust}
5315+
# #![allow(deprecated)]
53155316
use std::sync::Future;
53165317
53175318
let mut delayed_value = Future::spawn(move || {

src/doc/reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,9 +1480,9 @@ data are being stored, or single-address and mutability properties are required.
14801480
```
14811481
use std::sync::atomic;
14821482
1483-
// Note that INIT_ATOMIC_UINT is a *const*, but it may be used to initialize a
1483+
// Note that ATOMIC_UINT_INIT is a *const*, but it may be used to initialize a
14841484
// static. This static can be modified, so it is not placed in read-only memory.
1485-
static COUNTER: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
1485+
static COUNTER: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT;
14861486
14871487
// This table is a candidate to be placed in read-only memory.
14881488
static TABLE: &'static [uint] = &[1, 2, 3, /* ... */];

src/libcollections/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2263,7 +2263,7 @@ mod tests {
22632263
}
22642264
}
22652265
const NUM_ELEMENTS: uint = 2;
2266-
static DROP_COUNTER: AtomicUint = atomic::INIT_ATOMIC_UINT;
2266+
static DROP_COUNTER: AtomicUint = atomic::ATOMIC_UINT_INIT;
22672267

22682268
let v = Vec::from_elem(NUM_ELEMENTS, Nothing);
22692269

src/libcore/atomic.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,27 @@ pub enum Ordering {
8989

9090
/// An `AtomicBool` initialized to `false`.
9191
#[unstable = "may be renamed, pending conventions for static initalizers"]
92-
pub const INIT_ATOMIC_BOOL: AtomicBool =
92+
pub const ATOMIC_BOOL_INIT: AtomicBool =
9393
AtomicBool { v: UnsafeCell { value: 0 } };
9494
/// An `AtomicInt` initialized to `0`.
9595
#[unstable = "may be renamed, pending conventions for static initalizers"]
96-
pub const INIT_ATOMIC_INT: AtomicInt =
96+
pub const ATOMIC_INT_INIT: AtomicInt =
9797
AtomicInt { v: UnsafeCell { value: 0 } };
9898
/// An `AtomicUint` initialized to `0`.
9999
#[unstable = "may be renamed, pending conventions for static initalizers"]
100-
pub const INIT_ATOMIC_UINT: AtomicUint =
100+
pub const ATOMIC_UINT_INIT: AtomicUint =
101101
AtomicUint { v: UnsafeCell { value: 0, } };
102102

103+
/// Deprecated
104+
#[deprecated = "renamed to ATOMIC_BOOL_INIT"]
105+
pub const INIT_ATOMIC_BOOL: AtomicBool = ATOMIC_BOOL_INIT;
106+
/// Deprecated
107+
#[deprecated = "renamed to ATOMIC_INT_INIT"]
108+
pub const INIT_ATOMIC_INT: AtomicInt = ATOMIC_INT_INIT;
109+
/// Deprecated
110+
#[deprecated = "renamed to ATOMIC_UINT_INIT"]
111+
pub const INIT_ATOMIC_UINT: AtomicUint = ATOMIC_UINT_INIT;
112+
103113
// NB: Needs to be -1 (0b11111111...) to make fetch_nand work correctly
104114
const UINT_TRUE: uint = -1;
105115

src/libcore/cell.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@
155155
// FIXME: Can't be shared between threads. Dynamic borrows
156156
// FIXME: Relationship to Atomic types and RWLock
157157

158+
#![stable]
159+
158160
use clone::Clone;
159161
use cmp::PartialEq;
160162
use default::Default;

src/libcoretest/atomic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ fn int_xor() {
7070
assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
7171
}
7272

73-
static S_BOOL : AtomicBool = INIT_ATOMIC_BOOL;
74-
static S_INT : AtomicInt = INIT_ATOMIC_INT;
75-
static S_UINT : AtomicUint = INIT_ATOMIC_UINT;
73+
static S_BOOL : AtomicBool = ATOMIC_BOOL_INIT;
74+
static S_INT : AtomicInt = ATOMIC_INT_INIT;
75+
static S_UINT : AtomicUint = ATOMIC_UINT_INIT;
7676

7777
#[test]
7878
fn static_init() {

src/liblog/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ pub struct LogLocation {
352352
#[doc(hidden)]
353353
pub fn mod_enabled(level: u32, module: &str) -> bool {
354354
static INIT: Once = ONCE_INIT;
355-
INIT.doit(init);
355+
INIT.call_once(init);
356356

357357
// It's possible for many threads are in this function, only one of them
358358
// will perform the global initialization, but all of them will need to check

src/librustc/middle/infer/region_inference/graphviz.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
7373
let output_path = {
7474
let output_template = match requested_output {
7575
Some(ref s) if s.as_slice() == "help" => {
76-
static PRINTED_YET : atomic::AtomicBool = atomic::INIT_ATOMIC_BOOL;
76+
static PRINTED_YET : atomic::AtomicBool = atomic::ATOMIC_BOOL_INIT;
7777
if !PRINTED_YET.load(atomic::SeqCst) {
7878
print_help_message();
7979
PRINTED_YET.store(true, atomic::SeqCst);

src/librustc_trans/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ unsafe fn configure_llvm(sess: &Session) {
10091009
}
10101010
}
10111011

1012-
INIT.doit(|| {
1012+
INIT.call_once(|| {
10131013
llvm::LLVMInitializePasses();
10141014

10151015
// Only initialize the platforms supported by Rust here, because

0 commit comments

Comments
 (0)