Skip to content

Commit b87ed60

Browse files
committed
std: Rename unstable::mutex::Mutex to StaticNativeMutex.
This better reflects its purpose and design.
1 parent 75d92db commit b87ed60

File tree

13 files changed

+69
-65
lines changed

13 files changed

+69
-65
lines changed

src/libgreen/sched.rs

Lines changed: 4 additions & 4 deletions
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::Mutex;
18+
use std::unstable::mutex::StaticNativeMutex;
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 Mutex = &mut task.nasty_deschedule_lock;
767+
let lock: *mut StaticNativeMutex = &mut task.nasty_deschedule_lock;
768768
unsafe {
769769
let _guard = (*lock).lock();
770770
f(sched, BlockedTask::block(task.swap()));
@@ -1453,8 +1453,8 @@ mod test {
14531453

14541454
#[test]
14551455
fn test_spawn_sched_blocking() {
1456-
use std::unstable::mutex::{Mutex, MUTEX_INIT};
1457-
static mut LOCK: Mutex = MUTEX_INIT;
1456+
use std::unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
1457+
static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
14581458

14591459
// Testing that a task in one scheduler can block in foreign code
14601460
// without affecting other schedulers

src/libgreen/task.rs

Lines changed: 4 additions & 4 deletions
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::Mutex;
28+
use std::unstable::mutex::StaticNativeMutex;
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: Mutex,
68+
nasty_deschedule_lock: StaticNativeMutex,
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 { Mutex::new() },
166+
nasty_deschedule_lock: unsafe { StaticNativeMutex::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 Mutex;
325+
let mtx = &mut self.nasty_deschedule_lock as *mut StaticNativeMutex;
326326
let handle = self.handle.get_mut_ref() as *mut SchedHandle;
327327
let _guard = (*mtx).lock();
328328
(*handle).send(RunOnce(self));

src/libnative/bookkeeping.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
//! The green counterpart for this is bookkeeping on sched pools.
1818
1919
use std::sync::atomics;
20-
use std::unstable::mutex::{Mutex, MUTEX_INIT};
20+
use std::unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
2121

2222
static mut TASK_COUNT: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT;
23-
static mut TASK_LOCK: Mutex = MUTEX_INIT;
23+
static mut TASK_LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
2424

2525
pub fn increment() {
2626
let _ = unsafe { TASK_COUNT.fetch_add(1, atomics::SeqCst) };

src/libnative/io/net.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ pub fn init() {
218218
}
219219

220220
unsafe {
221-
use std::unstable::mutex::{Mutex, MUTEX_INIT};
221+
use std::unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
222222
static mut INITIALIZED: bool = false;
223-
static mut LOCK: Mutex = MUTEX_INIT;
223+
static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
224224

225225
let _guard = LOCK.lock();
226226
if !INITIALIZED {

src/libnative/io/timer_helper.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
2323
use std::cast;
2424
use std::rt;
25-
use std::unstable::mutex::{Mutex, MUTEX_INIT};
25+
use std::unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
2626

2727
use bookkeeping;
2828
use io::timer::{Req, Shutdown};
@@ -37,7 +37,7 @@ static mut HELPER_CHAN: *mut Chan<Req> = 0 as *mut Chan<Req>;
3737
static mut HELPER_SIGNAL: imp::signal = 0 as imp::signal;
3838

3939
pub fn boot(helper: fn(imp::signal, Port<Req>)) {
40-
static mut LOCK: Mutex = MUTEX_INIT;
40+
static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
4141
static mut INITIALIZED: bool = false;
4242

4343
unsafe {

src/libnative/task.rs

Lines changed: 3 additions & 3 deletions
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::Mutex;
25+
use std::unstable::mutex::StaticNativeMutex;
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 { Mutex::new() },
43+
lock: unsafe { StaticNativeMutex::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: Mutex, // native synchronization
112+
lock: StaticNativeMutex, // native synchronization
113113
awoken: bool, // used to prevent spurious wakeups
114114
io: io::IoFactory, // local I/O factory
115115

src/libstd/comm/shared.rs

Lines changed: 3 additions & 3 deletions
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::Mutex;
31+
use unstable::mutex::StaticNativeMutex;
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: Mutex,
56+
select_lock: StaticNativeMutex,
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 { Mutex::new() },
75+
select_lock: unsafe { StaticNativeMutex::new() },
7676
};
7777
// see comments in inherit_blocker about why we grab this lock
7878
unsafe { p.select_lock.lock_noguard() }

src/libstd/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ Accessing environment variables is not generally threadsafe.
144144
Serialize access through a global lock.
145145
*/
146146
fn with_env_lock<T>(f: || -> T) -> T {
147-
use unstable::mutex::{Mutex, MUTEX_INIT};
147+
use unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
148148

149-
static mut lock: Mutex = MUTEX_INIT;
149+
static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
150150

151151
unsafe {
152152
let _guard = lock.lock();

src/libstd/rt/args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ mod imp {
6868
use option::{Option, Some, None};
6969
use ptr::RawPtr;
7070
use iter::Iterator;
71-
use unstable::mutex::{Mutex, MUTEX_INIT};
71+
use unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
7272
use mem;
7373

7474
static mut global_args_ptr: uint = 0;
75-
static mut lock: Mutex = MUTEX_INIT;
75+
static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
7676

7777
#[cfg(not(test))]
7878
pub unsafe fn init(argc: int, argv: **u8) {

src/libstd/unstable/dynamic_lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ pub mod dl {
152152
}
153153

154154
pub fn check_for_errors_in<T>(f: || -> T) -> Result<T, ~str> {
155-
use unstable::mutex::{Mutex, MUTEX_INIT};
156-
static mut lock: Mutex = MUTEX_INIT;
155+
use unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
156+
static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
157157
unsafe {
158158
// dlerror isn't thread safe, so we need to lock around this entire
159159
// sequence

0 commit comments

Comments
 (0)