Various bug fixes and rebase conflicts
This commit is contained in:
parent
984727ff87
commit
acacfb20fd
@ -89,13 +89,6 @@ pub static NATIVE_BLOCKED: uint = 1 << 2;
|
||||
/// 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 @@ mod test {
|
||||
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);
|
||||
|
@ -30,7 +30,7 @@ use sync::mutex::{StaticMutex, MUTEX_INIT};
|
||||
/// # 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 @@ mod test {
|
||||
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 @@ mod test {
|
||||
assert!(run);
|
||||
}
|
||||
c.send(());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
unsafe {
|
||||
|
@ -1470,7 +1470,6 @@ mod test {
|
||||
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 @@ mod test {
|
||||
fin_po.recv();
|
||||
pool.shutdown();
|
||||
}
|
||||
|
||||
unsafe { LOCK.destroy(); }
|
||||
}
|
||||
}
|
||||
|
@ -204,17 +204,16 @@ pub fn init() {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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_CHAN: *mut SharedChan<Req> = 0 as *mut SharedChan<Req>;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -384,7 +384,7 @@ impl<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 } }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user