Various bug fixes and rebase conflicts

This commit is contained in:
Alex Crichton
2014-01-27 22:41:25 -08:00
parent 984727ff87
commit acacfb20fd
7 changed files with 24 additions and 30 deletions
+2 -9
View File
@@ -89,13 +89,6 @@
/// let guard = m.lock();
/// // do some work
/// drop(guard); // unlock the lock
///
/// {
/// let _g = m.lock();
/// // do some work in a scope
/// }
///
/// // now the mutex is unlocked
/// ```
pub struct Mutex {
priv lock: StaticMutex,
@@ -541,9 +534,9 @@ fn inc() {
let (p, c) = SharedChan::new();
for _ in range(0, N) {
let c2 = c.clone();
do native::task::spawn { inc(); c2.send(()); }
native::task::spawn(proc() { inc(); c2.send(()); });
let c2 = c.clone();
do spawn { inc(); c2.send(()); }
spawn(proc() { inc(); c2.send(()); });
}
drop(c);
+3 -3
View File
@@ -30,7 +30,7 @@
/// # Example
///
/// ```rust
/// use std::unstable::mutex::{Once, ONCE_INIT};
/// use extra::sync::one::{Once, ONCE_INIT};
///
/// static mut START: Once = ONCE_INIT;
/// unsafe {
@@ -140,7 +140,7 @@ fn stampede_once() {
let (p, c) = SharedChan::new();
for _ in range(0, 10) {
let c = c.clone();
do spawn {
spawn(proc() {
for _ in range(0, 4) { task::deschedule() }
unsafe {
o.doit(|| {
@@ -150,7 +150,7 @@ fn stampede_once() {
assert!(run);
}
c.send(());
}
});
}
unsafe {
+1 -2
View File
@@ -1470,7 +1470,6 @@ fn pingpong(po: &Port<int>, ch: &Chan<int>) {
LOCK.signal(); // wakeup waiting scheduler
LOCK.wait(); // wait for them to grab the lock
LOCK.unlock();
LOCK.destroy(); // now we're guaranteed they have no locks
}
})));
drop(handle);
@@ -1478,6 +1477,6 @@ fn pingpong(po: &Port<int>, ch: &Chan<int>) {
fin_po.recv();
pool.shutdown();
}
unsafe { LOCK.destroy(); }
}
}
+9 -10
View File
@@ -204,17 +204,16 @@ fn WSAStartup(wVersionRequested: libc::WORD,
use std::unstable::mutex::{Mutex, MUTEX_INIT};
static mut INITIALIZED: bool = false;
static mut LOCK: Mutex = MUTEX_INIT;
unsafe {
LOCK.lock();
if !INITIALIZED {
let mut data: WSADATA = intrinsics::init();
let ret = WSAStartup(0x202, // version 2.2
&mut data);
assert_eq!(ret, 0);
INITIALIZED = true;
}
LOCK.unlock();
LOCK.lock();
if !INITIALIZED {
let mut data: WSADATA = intrinsics::init();
let ret = WSAStartup(0x202, // version 2.2
&mut data);
assert_eq!(ret, 0);
INITIALIZED = true;
}
LOCK.unlock();
}
}
+8 -4
View File
@@ -22,7 +22,7 @@
use std::cast;
use std::rt;
use std::unstable::mutex::{Once, ONCE_INIT};
use std::unstable::mutex::{Mutex, MUTEX_INIT};
use bookkeeping;
use io::timer::{Req, Shutdown};
@@ -37,10 +37,12 @@
static mut HELPER_SIGNAL: imp::signal = 0 as imp::signal;
pub fn boot(helper: fn(imp::signal, Port<Req>)) {
static mut INIT: Once = ONCE_INIT;
static mut LOCK: Mutex = MUTEX_INIT;
static mut INITIALIZED: bool = false;
unsafe {
INIT.doit(|| {
LOCK.lock();
if !INITIALIZED {
let (msgp, msgc) = SharedChan::new();
HELPER_CHAN = cast::transmute(~msgc);
let (receive, send) = imp::new();
@@ -52,7 +54,9 @@ pub fn boot(helper: fn(imp::signal, Port<Req>)) {
});
rt::at_exit(proc() { shutdown() });
})
INITIALIZED = true;
}
LOCK.unlock();
}
}
-1
View File
@@ -96,7 +96,6 @@ pub mod write {
use lib::llvm::llvm;
use lib::llvm::{ModuleRef, TargetMachineRef, PassManagerRef};
use lib;
use syntax::abi;
use util::common::time;
use syntax::abi;
+1 -1
View File
@@ -384,7 +384,7 @@ pub fn new(p: ~T) -> AtomicOption<T> {
}
#[cfg(stage0)]
pub fn empty() -> AtomicOption<T> { AtomicOption { p: 0 as *mut c_void } }
pub fn empty() -> AtomicOption<T> { AtomicOption { p: 0 as *mut u8 } }
#[cfg(not(stage0))]
pub fn empty() -> AtomicOption<T> { AtomicOption { p: 0 } }