Skip to content

Commit ec19311

Browse files
committed
---
yaml --- r: 60563 b: refs/heads/auto c: 18fab45 h: refs/heads/master i: 60561: ffa51fe 60559: cc516eb v: v3
1 parent ec821f4 commit ec19311

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 71aa6b6631547a7b2e6839931e73286e0bf6ce5d
17+
refs/heads/auto: 18fab45aab8622b0bfbcd336d57652bfb2f4f4ac
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/libcore/rt/local.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,21 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use rt::sched::Scheduler;
12+
use rt::local_ptr;
13+
1114
pub trait Local {
1215
fn put_local(value: ~Self);
1316
fn take_local() -> ~Self;
14-
fn exists() -> bool;
15-
fn borrow(f: &fn(&mut Self));
16-
fn unsafe_borrow() -> *mut Self;
17+
fn exists_local() -> bool;
18+
fn borrow_local(f: &fn(&mut Self));
19+
unsafe fn unsafe_borrow_local() -> *mut Self;
1720
}
21+
22+
impl Local for Scheduler {
23+
fn put_local(value: ~Scheduler) { unsafe { local_ptr::put(value) }}
24+
fn take_local() -> ~Scheduler { unsafe { local_ptr::take() } }
25+
fn exists_local() -> bool { local_ptr::exists() }
26+
fn borrow_local(f: &fn(&mut Scheduler)) { unsafe { local_ptr::borrow(f) } }
27+
unsafe fn unsafe_borrow_local() -> *mut Scheduler { local_ptr::unsafe_borrow() }
28+
}

branches/auto/src/libcore/rt/local_sched.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,30 @@ use rt::rtio::{EventLoop, IoFactoryObject};
2121
use unstable::finally::Finally;
2222
use rt::local_ptr;
2323
use tls = rt::thread_local_storage;
24+
use rt::local::Local;
2425

2526
#[cfg(test)] use rt::uv::uvio::UvEventLoop;
2627

2728
/// Give the Scheduler to thread-local storage
28-
pub fn put(sched: ~Scheduler) { unsafe { local_ptr::put(sched) } }
29+
pub fn put(sched: ~Scheduler) { Local::put_local(sched) }
2930

3031
/// Take ownership of the Scheduler from thread-local storage
31-
pub fn take() -> ~Scheduler { unsafe { local_ptr::take() } }
32+
pub fn take() -> ~Scheduler { Local::take_local() }
3233

3334
/// Check whether there is a thread-local Scheduler attached to the running thread
34-
pub fn exists() -> bool { local_ptr::exists() }
35+
pub fn exists() -> bool { Local::exists_local::<Scheduler>() }
3536

3637
/// Borrow the thread-local scheduler from thread-local storage.
3738
/// While the scheduler is borrowed it is not available in TLS.
38-
pub fn borrow(f: &fn(&mut Scheduler)) { unsafe { local_ptr::borrow(f) } }
39+
pub fn borrow(f: &fn(&mut Scheduler)) { Local::borrow_local(f) }
3940

4041
/// Borrow a mutable reference to the thread-local Scheduler
4142
///
4243
/// # Safety Note
4344
///
4445
/// Because this leaves the Scheduler in thread-local storage it is possible
4546
/// For the Scheduler pointer to be aliased
46-
pub unsafe fn unsafe_borrow() -> *mut Scheduler { local_ptr::unsafe_borrow() }
47+
pub unsafe fn unsafe_borrow() -> *mut Scheduler { Local::unsafe_borrow_local() }
4748

4849
pub unsafe fn unsafe_borrow_io() -> *mut IoFactoryObject {
4950
let sched = unsafe_borrow();

0 commit comments

Comments
 (0)