diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-11-14 00:21:43 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-11-18 20:06:40 -0800 |
| commit | e8bf0788027932a0b547819cc9edd13c40426e36 (patch) | |
| tree | 9f64d86fc4275a096ad2236c198451a663c665be /src/libstd/task | |
| parent | 24eb1b445dd878c12ca6503a9fa040179b94e614 (diff) | |
| download | rust-e8bf0788027932a0b547819cc9edd13c40426e36.tar.gz rust-e8bf0788027932a0b547819cc9edd13c40426e36.zip | |
Remove the C++ lock_and_signal type
A the same time this purges all runtime support needed for statically initialized mutexes, moving all users over to the new Mutex type instead.
Diffstat (limited to 'src/libstd/task')
| -rw-r--r-- | src/libstd/task/mod.rs | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs index 51c11b69972..5a2251eaa46 100644 --- a/src/libstd/task/mod.rs +++ b/src/libstd/task/mod.rs @@ -1141,22 +1141,10 @@ fn test_spawn_sched_childs_on_default_sched() { po.recv(); } -#[cfg(test)] -mod testrt { - use libc; - - extern { - pub fn rust_dbg_lock_create() -> *libc::c_void; - pub fn rust_dbg_lock_destroy(lock: *libc::c_void); - pub fn rust_dbg_lock_lock(lock: *libc::c_void); - pub fn rust_dbg_lock_unlock(lock: *libc::c_void); - pub fn rust_dbg_lock_wait(lock: *libc::c_void); - pub fn rust_dbg_lock_signal(lock: *libc::c_void); - } -} - #[test] fn test_spawn_sched_blocking() { + use unstable::mutex::Mutex; + unsafe { // Testing that a task in one scheduler can block in foreign code @@ -1165,16 +1153,18 @@ fn test_spawn_sched_blocking() { let (start_po, start_ch) = stream(); let (fin_po, fin_ch) = stream(); - let lock = testrt::rust_dbg_lock_create(); + let mut lock = Mutex::new(); + let lock2 = Cell::new(lock.clone()); do spawn_sched(SingleThreaded) { - testrt::rust_dbg_lock_lock(lock); + let mut lock = lock2.take(); + lock.lock(); start_ch.send(()); // Block the scheduler thread - testrt::rust_dbg_lock_wait(lock); - testrt::rust_dbg_lock_unlock(lock); + lock.wait(); + lock.unlock(); fin_ch.send(()); }; @@ -1201,11 +1191,11 @@ fn test_spawn_sched_blocking() { let child_ch = setup_po.recv(); child_ch.send(20); pingpong(&parent_po, &child_ch); - testrt::rust_dbg_lock_lock(lock); - testrt::rust_dbg_lock_signal(lock); - testrt::rust_dbg_lock_unlock(lock); + lock.lock(); + lock.signal(); + lock.unlock(); fin_po.recv(); - testrt::rust_dbg_lock_destroy(lock); + lock.destroy(); } } } |
