diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-02-15 15:01:00 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-02-16 10:13:56 +1100 |
| commit | 4668cdf3c4788e4a67f1b7dea0eb2d661ac05a49 (patch) | |
| tree | 040ab0c33642c93b68c44fdd3db594cacab64a42 | |
| parent | 5d86e24ab27dba0a773bd00a98e3845ece0ebf16 (diff) | |
| download | rust-4668cdf3c4788e4a67f1b7dea0eb2d661ac05a49.tar.gz rust-4668cdf3c4788e4a67f1b7dea0eb2d661ac05a49.zip | |
Convert some unnecessary StaticNativeMutexes to NativeMutexes.
| -rw-r--r-- | src/libgreen/sched.rs | 4 | ||||
| -rw-r--r-- | src/libgreen/task.rs | 14 | ||||
| -rw-r--r-- | src/libnative/task.rs | 12 | ||||
| -rw-r--r-- | src/libstd/comm/shared.rs | 7 |
4 files changed, 12 insertions, 25 deletions
diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index bf6a6d54220..ad32ba7ba6d 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -15,7 +15,7 @@ use std::rt::rtio::{RemoteCallback, PausableIdleCallback, Callback, EventLoop}; use std::rt::task::BlockedTask; use std::rt::task::Task; use std::sync::deque; -use std::unstable::mutex::StaticNativeMutex; +use std::unstable::mutex::NativeMutex; use std::unstable::raw; use TaskState; @@ -764,7 +764,7 @@ impl Scheduler { // to it, but we're guaranteed that the task won't exit until we've // unlocked the lock so there's no worry of this memory going away. let cur = self.change_task_context(cur, next, |sched, mut task| { - let lock: *mut StaticNativeMutex = &mut task.nasty_deschedule_lock; + let lock: *mut NativeMutex = &mut task.nasty_deschedule_lock; unsafe { let _guard = (*lock).lock(); f(sched, BlockedTask::block(task.swap())); diff --git a/src/libgreen/task.rs b/src/libgreen/task.rs index c0c0ef3e24f..74d93b4b2db 100644 --- a/src/libgreen/task.rs +++ b/src/libgreen/task.rs @@ -25,7 +25,7 @@ use std::rt::local::Local; use std::rt::rtio; use std::rt::task::{Task, BlockedTask, SendMessage}; use std::task::TaskOpts; -use std::unstable::mutex::StaticNativeMutex; +use std::unstable::mutex::NativeMutex; use std::unstable::raw; use context::Context; @@ -65,7 +65,7 @@ pub struct GreenTask { pool_id: uint, // See the comments in the scheduler about why this is necessary - nasty_deschedule_lock: StaticNativeMutex, + nasty_deschedule_lock: NativeMutex, } pub enum TaskType { @@ -163,7 +163,7 @@ impl GreenTask { task_type: task_type, sched: None, handle: None, - nasty_deschedule_lock: unsafe { StaticNativeMutex::new() }, + nasty_deschedule_lock: unsafe { NativeMutex::new() }, task: Some(~Task::new()), } } @@ -322,7 +322,7 @@ impl GreenTask { // uncontended except for when the task is rescheduled). fn reawaken_remotely(mut ~self) { unsafe { - let mtx = &mut self.nasty_deschedule_lock as *mut StaticNativeMutex; + let mtx = &mut self.nasty_deschedule_lock as *mut NativeMutex; let handle = self.handle.get_mut_ref() as *mut SchedHandle; let _guard = (*mtx).lock(); (*handle).send(RunOnce(self)); @@ -478,12 +478,6 @@ impl Runtime for GreenTask { fn wrap(~self) -> ~Any { self as ~Any } } -impl Drop for GreenTask { - fn drop(&mut self) { - unsafe { self.nasty_deschedule_lock.destroy(); } - } -} - #[cfg(test)] mod tests { use std::rt::Runtime; diff --git a/src/libnative/task.rs b/src/libnative/task.rs index e4a8c45eb0b..d8f410834f2 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -22,7 +22,7 @@ use std::rt::task::{Task, BlockedTask, SendMessage}; use std::rt::thread::Thread; use std::rt; use std::task::TaskOpts; -use std::unstable::mutex::StaticNativeMutex; +use std::unstable::mutex::NativeMutex; use std::unstable::stack; use io; @@ -40,7 +40,7 @@ pub fn new(stack_bounds: (uint, uint)) -> ~Task { fn ops() -> ~Ops { ~Ops { - lock: unsafe { StaticNativeMutex::new() }, + lock: unsafe { NativeMutex::new() }, awoken: false, io: io::IoFactory::new(), // these *should* get overwritten @@ -109,7 +109,7 @@ pub fn spawn_opts(opts: TaskOpts, f: proc()) { // This structure is the glue between channels and the 1:1 scheduling mode. This // structure is allocated once per task. struct Ops { - lock: StaticNativeMutex, // native synchronization + lock: NativeMutex, // native synchronization awoken: bool, // used to prevent spurious wakeups io: io::IoFactory, // local I/O factory @@ -251,12 +251,6 @@ impl rt::Runtime for Ops { } } -impl Drop for Ops { - fn drop(&mut self) { - unsafe { self.lock.destroy() } - } -} - #[cfg(test)] mod tests { use std::rt::Runtime; diff --git a/src/libstd/comm/shared.rs b/src/libstd/comm/shared.rs index 61fc700c3c0..031ce991ba4 100644 --- a/src/libstd/comm/shared.rs +++ b/src/libstd/comm/shared.rs @@ -28,7 +28,7 @@ use rt::local::Local; use rt::task::{Task, BlockedTask}; use rt::thread::Thread; use sync::atomics; -use unstable::mutex::StaticNativeMutex; +use unstable::mutex::NativeMutex; use vec::OwnedVector; use mpsc = sync::mpsc_queue; @@ -53,7 +53,7 @@ pub struct Packet<T> { // this lock protects various portions of this implementation during // select() - select_lock: StaticNativeMutex, + select_lock: NativeMutex, } pub enum Failure { @@ -72,7 +72,7 @@ impl<T: Send> Packet<T> { channels: atomics::AtomicInt::new(2), port_dropped: atomics::AtomicBool::new(false), sender_drain: atomics::AtomicInt::new(0), - select_lock: unsafe { StaticNativeMutex::new() }, + select_lock: unsafe { NativeMutex::new() }, }; // see comments in inherit_blocker about why we grab this lock unsafe { p.select_lock.lock_noguard() } @@ -486,7 +486,6 @@ impl<T: Send> Drop for Packet<T> { assert_eq!(self.cnt.load(atomics::SeqCst), DISCONNECTED); assert_eq!(self.to_wake.load(atomics::SeqCst), 0); assert_eq!(self.channels.load(atomics::SeqCst), 0); - self.select_lock.destroy(); } } } |
