rollup merge of #20315: alexcrichton/std-sync
Conflicts: src/libstd/rt/exclusive.rs src/libstd/sync/barrier.rs src/libstd/sys/unix/pipe.rs src/test/bench/shootout-binarytrees.rs src/test/bench/shootout-fannkuch-redux.rs
This commit is contained in:
commit
009ec5d2b0
45 changed files with 167 additions and 792 deletions
|
|
@ -11,12 +11,12 @@
|
|||
use std::sync::atomic;
|
||||
|
||||
pub const C1: uint = 1;
|
||||
pub const C2: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
|
||||
pub const C2: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT;
|
||||
pub const C3: fn() = foo;
|
||||
pub const C4: uint = C1 * C1 + C1 / C1;
|
||||
pub const C5: &'static uint = &C4;
|
||||
|
||||
pub static S1: uint = 3;
|
||||
pub static S2: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
|
||||
pub static S2: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT;
|
||||
|
||||
fn foo() {}
|
||||
|
|
|
|||
|
|
@ -41,9 +41,7 @@
|
|||
extern crate arena;
|
||||
|
||||
use std::iter::range_step;
|
||||
use std::str::from_str;
|
||||
use std::sync::Future;
|
||||
|
||||
use std::thread::Thread;
|
||||
use arena::TypedArena;
|
||||
|
||||
enum Tree<'a> {
|
||||
|
|
@ -97,7 +95,7 @@ fn main() {
|
|||
let mut messages = range_step(min_depth, max_depth + 1, 2).map(|depth| {
|
||||
use std::num::Int;
|
||||
let iterations = 2i.pow((max_depth - depth + min_depth) as uint);
|
||||
Future::spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut chk = 0;
|
||||
for i in range(1, iterations + 1) {
|
||||
let arena = TypedArena::new();
|
||||
|
|
@ -108,10 +106,10 @@ fn main() {
|
|||
format!("{}\t trees of depth {}\t check: {}",
|
||||
iterations * 2, depth, chk)
|
||||
})
|
||||
}).collect::<Vec<Future<String>>>();
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
for message in messages.iter_mut() {
|
||||
println!("{}", *message.get_ref());
|
||||
for message in messages.into_iter() {
|
||||
println!("{}", message.join().ok().unwrap());
|
||||
}
|
||||
|
||||
println!("long lived tree of depth {}\t check: {}",
|
||||
|
|
|
|||
|
|
@ -40,9 +40,8 @@
|
|||
|
||||
#![feature(slicing_syntax)]
|
||||
|
||||
use std::str::from_str;
|
||||
use std::sync::Future;
|
||||
use std::{cmp, iter, mem};
|
||||
use std::thread::Thread;
|
||||
|
||||
fn rotate(x: &mut [i32]) {
|
||||
let mut prev = x[0];
|
||||
|
|
@ -169,15 +168,15 @@ fn fannkuch(n: i32) -> (i32, i32) {
|
|||
for (i, j) in range(0, N).zip(iter::count(0, k)) {
|
||||
let max = cmp::min(j+k, perm.max());
|
||||
|
||||
futures.push(Future::spawn(move|| {
|
||||
futures.push(Thread::spawn(move|| {
|
||||
work(perm, j as uint, max as uint)
|
||||
}))
|
||||
}
|
||||
|
||||
let mut checksum = 0;
|
||||
let mut maxflips = 0;
|
||||
for fut in futures.iter_mut() {
|
||||
let (cs, mf) = fut.get();
|
||||
for fut in futures.into_iter() {
|
||||
let (cs, mf) = fut.join().ok().unwrap();
|
||||
checksum += cs;
|
||||
maxflips = cmp::max(maxflips, mf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ use std::sync::atomic::*;
|
|||
use std::ptr;
|
||||
|
||||
fn main() {
|
||||
let x = INIT_ATOMIC_BOOL;
|
||||
let x = ATOMIC_BOOL_INIT;
|
||||
let x = *&x; //~ ERROR: cannot move out of dereference
|
||||
let x = INIT_ATOMIC_INT;
|
||||
let x = ATOMIC_INT_INIT;
|
||||
let x = *&x; //~ ERROR: cannot move out of dereference
|
||||
let x = INIT_ATOMIC_UINT;
|
||||
let x = ATOMIC_UINT_INIT;
|
||||
let x = *&x; //~ ERROR: cannot move out of dereference
|
||||
let x: AtomicPtr<uint> = AtomicPtr::new(ptr::null_mut());
|
||||
let x = *&x; //~ ERROR: cannot move out of dereference
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ extern crate "issue-17718" as other;
|
|||
use std::sync::atomic;
|
||||
|
||||
const C1: uint = 1;
|
||||
const C2: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
|
||||
const C2: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT;
|
||||
const C3: fn() = foo;
|
||||
const C4: uint = C1 * C1 + C1 / C1;
|
||||
const C5: &'static uint = &C4;
|
||||
|
|
@ -25,7 +25,7 @@ const C6: uint = {
|
|||
};
|
||||
|
||||
static S1: uint = 3;
|
||||
static S2: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
|
||||
static S2: atomic::AtomicUint = atomic::ATOMIC_UINT_INIT;
|
||||
|
||||
mod test {
|
||||
static A: uint = 4;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::task;
|
||||
use std::sync::atomic::{AtomicUint, INIT_ATOMIC_UINT, Relaxed};
|
||||
use std::sync::atomic::{AtomicUint, ATOMIC_UINT_INIT, Relaxed};
|
||||
use std::rand::{thread_rng, Rng, Rand};
|
||||
|
||||
const REPEATS: uint = 5;
|
||||
|
|
@ -17,18 +17,18 @@ const MAX_LEN: uint = 32;
|
|||
static drop_counts: [AtomicUint; MAX_LEN] =
|
||||
// FIXME #5244: AtomicUint is not Copy.
|
||||
[
|
||||
INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
|
||||
INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
|
||||
INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
|
||||
INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
|
||||
ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
|
||||
ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
|
||||
ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
|
||||
ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
|
||||
|
||||
INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
|
||||
INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
|
||||
INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
|
||||
INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT, INIT_ATOMIC_UINT,
|
||||
ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
|
||||
ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
|
||||
ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
|
||||
ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT, ATOMIC_UINT_INIT,
|
||||
];
|
||||
|
||||
static creation_count: AtomicUint = INIT_ATOMIC_UINT;
|
||||
static creation_count: AtomicUint = ATOMIC_UINT_INIT;
|
||||
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord)]
|
||||
struct DropCounter { x: uint, creation_id: uint }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue