Skip to content

Commit 2f99fb8

Browse files
committed
core::rt: Remove local_sched module
1 parent 06f1a64 commit 2f99fb8

File tree

8 files changed

+20
-53
lines changed

8 files changed

+20
-53
lines changed

src/libcore/rt/comm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use ops::Drop;
2222
use kinds::Owned;
2323
use rt::sched::{Scheduler, Coroutine};
2424
use rt::local::Local;
25-
use rt::local_sched;
2625
use unstable::intrinsics::{atomic_xchg, atomic_load};
2726
use util::Void;
2827
use comm::{GenericChan, GenericSmartChan, GenericPort, Peekable};

src/libcore/rt/io/net/tcp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use option::{Option, Some, None};
1212
use result::{Ok, Err};
13-
use rt::sched::local_sched::unsafe_borrow_io;
13+
use rt::sched::unsafe_borrow_io;
1414
use rt::io::net::ip::IpAddr;
1515
use rt::io::{Reader, Writer, Listener};
1616
use rt::io::{io_error, read_error, EndOfFile};

src/libcore/rt/local_sched.rs

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/libcore/rt/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ pub mod task;
6767
/// The coroutine task scheduler, built on the `io` event loop.
6868
mod sched;
6969

70-
/// Thread-local access to the current Scheduler.
71-
pub mod local_sched;
72-
7370
/// Synchronous I/O.
7471
#[path = "io/mod.rs"]
7572
pub mod io;
@@ -189,7 +186,7 @@ pub fn context() -> RuntimeContext {
189186

190187
use task::rt::rust_task;
191188
use self::local::Local;
192-
use self::sched::{local_sched, Scheduler};
189+
use self::sched::Scheduler;
193190

194191
// XXX: Hitting TLS twice to check if the scheduler exists
195192
// then to check for the task is not good for perf
@@ -220,7 +217,7 @@ pub fn context() -> RuntimeContext {
220217
#[test]
221218
fn test_context() {
222219
use unstable::run_in_bare_thread;
223-
use self::sched::{local_sched, Scheduler, Coroutine};
220+
use self::sched::{Scheduler, Coroutine};
224221
use rt::uv::uvio::UvEventLoop;
225222
use cell::Cell;
226223
use rt::local::Local;

src/libcore/rt/sched.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ use super::context::Context;
2020
use super::task::Task;
2121
use rt::local_ptr;
2222
use rt::local::Local;
23-
24-
// A more convenient name for external callers, e.g. `local_sched::take()`
25-
pub mod local_sched;
23+
use rt::rtio::IoFactoryObject;
2624

2725
/// The Scheduler is responsible for coordinating execution of Coroutines
2826
/// on a single thread. When the scheduler is running it is owned by
@@ -403,6 +401,12 @@ pub impl Coroutine {
403401
}
404402
}
405403

404+
pub unsafe fn unsafe_borrow_io() -> *mut IoFactoryObject {
405+
let sched = Local::unsafe_borrow::<Scheduler>();
406+
let io: *mut IoFactoryObject = (*sched).event_loop.io().unwrap();
407+
return io;
408+
}
409+
406410
#[cfg(test)]
407411
mod test {
408412
use int;

src/libcore/rt/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use prelude::*;
1717
use libc::{c_void, uintptr_t};
1818
use cast::transmute;
19-
use super::sched::{Scheduler, local_sched};
19+
use super::sched::Scheduler;
2020
use rt::local::Local;
2121
use super::local_heap::LocalHeap;
2222
use rt::logging::StdErrLogger;

src/libcore/rt/tube.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use clone::Clone;
1818
use super::rc::RC;
1919
use rt::sched::{Scheduler, Coroutine};
2020
use rt::{context, TaskContext, SchedulerContext};
21-
use rt::local_sched;
2221
use rt::local::Local;
2322
use vec::OwnedVector;
2423
use container::Container;
@@ -95,7 +94,6 @@ impl<T> Clone for Tube<T> {
9594
mod test {
9695
use int;
9796
use cell::Cell;
98-
use rt::local_sched;
9997
use rt::test::*;
10098
use rt::rtio::EventLoop;
10199
use rt::sched::Scheduler;

src/libcore/rt/uv/uvio.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ use rt::io::net::ip::IpAddr;
1919
use rt::uv::*;
2020
use rt::uv::idle::IdleWatcher;
2121
use rt::rtio::*;
22-
use rt::sched::{Scheduler, local_sched};
22+
use rt::sched::unsafe_borrow_io;
23+
use rt::sched::Scheduler;
2324
use rt::io::{standard_error, OtherIoError};
2425
use rt::tube::Tube;
2526
use rt::local::Local;
@@ -358,7 +359,7 @@ impl RtioTcpStream for UvTcpStream {
358359
fn test_simple_io_no_connect() {
359360
do run_in_newsched_task {
360361
unsafe {
361-
let io = local_sched::unsafe_borrow_io();
362+
let io = unsafe_borrow_io();
362363
let addr = next_test_ip4();
363364
let maybe_chan = (*io).tcp_connect(addr);
364365
assert!(maybe_chan.is_err());
@@ -374,7 +375,7 @@ fn test_simple_tcp_server_and_client() {
374375
// Start the server first so it's listening when we connect
375376
do spawntask_immediately {
376377
unsafe {
377-
let io = local_sched::unsafe_borrow_io();
378+
let io = unsafe_borrow_io();
378379
let mut listener = (*io).tcp_bind(addr).unwrap();
379380
let mut stream = listener.accept().unwrap();
380381
let mut buf = [0, .. 2048];
@@ -389,7 +390,7 @@ fn test_simple_tcp_server_and_client() {
389390

390391
do spawntask_immediately {
391392
unsafe {
392-
let io = local_sched::unsafe_borrow_io();
393+
let io = unsafe_borrow_io();
393394
let mut stream = (*io).tcp_connect(addr).unwrap();
394395
stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
395396
}
@@ -403,7 +404,7 @@ fn test_read_and_block() {
403404
let addr = next_test_ip4();
404405

405406
do spawntask_immediately {
406-
let io = unsafe { local_sched::unsafe_borrow_io() };
407+
let io = unsafe { unsafe_borrow_io() };
407408
let mut listener = unsafe { (*io).tcp_bind(addr).unwrap() };
408409
let mut stream = listener.accept().unwrap();
409410
let mut buf = [0, .. 2048];
@@ -439,7 +440,7 @@ fn test_read_and_block() {
439440

440441
do spawntask_immediately {
441442
unsafe {
442-
let io = local_sched::unsafe_borrow_io();
443+
let io = unsafe_borrow_io();
443444
let mut stream = (*io).tcp_connect(addr).unwrap();
444445
stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
445446
stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
@@ -459,7 +460,7 @@ fn test_read_read_read() {
459460

460461
do spawntask_immediately {
461462
unsafe {
462-
let io = local_sched::unsafe_borrow_io();
463+
let io = unsafe_borrow_io();
463464
let mut listener = (*io).tcp_bind(addr).unwrap();
464465
let mut stream = listener.accept().unwrap();
465466
let buf = [1, .. 2048];
@@ -473,7 +474,7 @@ fn test_read_read_read() {
473474

474475
do spawntask_immediately {
475476
unsafe {
476-
let io = local_sched::unsafe_borrow_io();
477+
let io = unsafe_borrow_io();
477478
let mut stream = (*io).tcp_connect(addr).unwrap();
478479
let mut buf = [0, .. 2048];
479480
let mut total_bytes_read = 0;

0 commit comments

Comments
 (0)