Skip to content

Commit 4668cdf

Browse files
committed
Convert some unnecessary StaticNativeMutexes to NativeMutexes.
1 parent 5d86e24 commit 4668cdf

File tree

4 files changed

+12
-25
lines changed

4 files changed

+12
-25
lines changed

src/libgreen/sched.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::rt::rtio::{RemoteCallback, PausableIdleCallback, Callback, EventLoop};
1515
use std::rt::task::BlockedTask;
1616
use std::rt::task::Task;
1717
use std::sync::deque;
18-
use std::unstable::mutex::StaticNativeMutex;
18+
use std::unstable::mutex::NativeMutex;
1919
use std::unstable::raw;
2020

2121
use TaskState;
@@ -764,7 +764,7 @@ impl Scheduler {
764764
// to it, but we're guaranteed that the task won't exit until we've
765765
// unlocked the lock so there's no worry of this memory going away.
766766
let cur = self.change_task_context(cur, next, |sched, mut task| {
767-
let lock: *mut StaticNativeMutex = &mut task.nasty_deschedule_lock;
767+
let lock: *mut NativeMutex = &mut task.nasty_deschedule_lock;
768768
unsafe {
769769
let _guard = (*lock).lock();
770770
f(sched, BlockedTask::block(task.swap()));

src/libgreen/task.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::rt::local::Local;
2525
use std::rt::rtio;
2626
use std::rt::task::{Task, BlockedTask, SendMessage};
2727
use std::task::TaskOpts;
28-
use std::unstable::mutex::StaticNativeMutex;
28+
use std::unstable::mutex::NativeMutex;
2929
use std::unstable::raw;
3030

3131
use context::Context;
@@ -65,7 +65,7 @@ pub struct GreenTask {
6565
pool_id: uint,
6666

6767
// See the comments in the scheduler about why this is necessary
68-
nasty_deschedule_lock: StaticNativeMutex,
68+
nasty_deschedule_lock: NativeMutex,
6969
}
7070

7171
pub enum TaskType {
@@ -163,7 +163,7 @@ impl GreenTask {
163163
task_type: task_type,
164164
sched: None,
165165
handle: None,
166-
nasty_deschedule_lock: unsafe { StaticNativeMutex::new() },
166+
nasty_deschedule_lock: unsafe { NativeMutex::new() },
167167
task: Some(~Task::new()),
168168
}
169169
}
@@ -322,7 +322,7 @@ impl GreenTask {
322322
// uncontended except for when the task is rescheduled).
323323
fn reawaken_remotely(mut ~self) {
324324
unsafe {
325-
let mtx = &mut self.nasty_deschedule_lock as *mut StaticNativeMutex;
325+
let mtx = &mut self.nasty_deschedule_lock as *mut NativeMutex;
326326
let handle = self.handle.get_mut_ref() as *mut SchedHandle;
327327
let _guard = (*mtx).lock();
328328
(*handle).send(RunOnce(self));
@@ -478,12 +478,6 @@ impl Runtime for GreenTask {
478478
fn wrap(~self) -> ~Any { self as ~Any }
479479
}
480480

481-
impl Drop for GreenTask {
482-
fn drop(&mut self) {
483-
unsafe { self.nasty_deschedule_lock.destroy(); }
484-
}
485-
}
486-
487481
#[cfg(test)]
488482
mod tests {
489483
use std::rt::Runtime;

src/libnative/task.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::rt::task::{Task, BlockedTask, SendMessage};
2222
use std::rt::thread::Thread;
2323
use std::rt;
2424
use std::task::TaskOpts;
25-
use std::unstable::mutex::StaticNativeMutex;
25+
use std::unstable::mutex::NativeMutex;
2626
use std::unstable::stack;
2727

2828
use io;
@@ -40,7 +40,7 @@ pub fn new(stack_bounds: (uint, uint)) -> ~Task {
4040

4141
fn ops() -> ~Ops {
4242
~Ops {
43-
lock: unsafe { StaticNativeMutex::new() },
43+
lock: unsafe { NativeMutex::new() },
4444
awoken: false,
4545
io: io::IoFactory::new(),
4646
// these *should* get overwritten
@@ -109,7 +109,7 @@ pub fn spawn_opts(opts: TaskOpts, f: proc()) {
109109
// This structure is the glue between channels and the 1:1 scheduling mode. This
110110
// structure is allocated once per task.
111111
struct Ops {
112-
lock: StaticNativeMutex, // native synchronization
112+
lock: NativeMutex, // native synchronization
113113
awoken: bool, // used to prevent spurious wakeups
114114
io: io::IoFactory, // local I/O factory
115115

@@ -251,12 +251,6 @@ impl rt::Runtime for Ops {
251251
}
252252
}
253253

254-
impl Drop for Ops {
255-
fn drop(&mut self) {
256-
unsafe { self.lock.destroy() }
257-
}
258-
}
259-
260254
#[cfg(test)]
261255
mod tests {
262256
use std::rt::Runtime;

src/libstd/comm/shared.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use rt::local::Local;
2828
use rt::task::{Task, BlockedTask};
2929
use rt::thread::Thread;
3030
use sync::atomics;
31-
use unstable::mutex::StaticNativeMutex;
31+
use unstable::mutex::NativeMutex;
3232
use vec::OwnedVector;
3333

3434
use mpsc = sync::mpsc_queue;
@@ -53,7 +53,7 @@ pub struct Packet<T> {
5353

5454
// this lock protects various portions of this implementation during
5555
// select()
56-
select_lock: StaticNativeMutex,
56+
select_lock: NativeMutex,
5757
}
5858

5959
pub enum Failure {
@@ -72,7 +72,7 @@ impl<T: Send> Packet<T> {
7272
channels: atomics::AtomicInt::new(2),
7373
port_dropped: atomics::AtomicBool::new(false),
7474
sender_drain: atomics::AtomicInt::new(0),
75-
select_lock: unsafe { StaticNativeMutex::new() },
75+
select_lock: unsafe { NativeMutex::new() },
7676
};
7777
// see comments in inherit_blocker about why we grab this lock
7878
unsafe { p.select_lock.lock_noguard() }
@@ -486,7 +486,6 @@ impl<T: Send> Drop for Packet<T> {
486486
assert_eq!(self.cnt.load(atomics::SeqCst), DISCONNECTED);
487487
assert_eq!(self.to_wake.load(atomics::SeqCst), 0);
488488
assert_eq!(self.channels.load(atomics::SeqCst), 0);
489-
self.select_lock.destroy();
490489
}
491490
}
492491
}

0 commit comments

Comments
 (0)