core::rt: Remove local_sched module

This commit is contained in:
Brian Anderson 2013-05-19 16:10:44 -07:00
parent 06f1a64bd6
commit 2f99fb8efa
8 changed files with 20 additions and 53 deletions

View File

@ -22,7 +22,6 @@ use ops::Drop;
use kinds::Owned;
use rt::sched::{Scheduler, Coroutine};
use rt::local::Local;
use rt::local_sched;
use unstable::intrinsics::{atomic_xchg, atomic_load};
use util::Void;
use comm::{GenericChan, GenericSmartChan, GenericPort, Peekable};

View File

@ -10,7 +10,7 @@
use option::{Option, Some, None};
use result::{Ok, Err};
use rt::sched::local_sched::unsafe_borrow_io;
use rt::sched::unsafe_borrow_io;
use rt::io::net::ip::IpAddr;
use rt::io::{Reader, Writer, Listener};
use rt::io::{io_error, read_error, EndOfFile};

View File

@ -1,32 +0,0 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Access to the thread-local Scheduler
use prelude::*;
use ptr::mut_null;
use libc::c_void;
use cast;
use cell::Cell;
use rt::sched::Scheduler;
use rt::rtio::{EventLoop, IoFactoryObject};
use unstable::finally::Finally;
use rt::local_ptr;
use tls = rt::thread_local_storage;
use rt::local::Local;
#[cfg(test)] use rt::uv::uvio::UvEventLoop;
pub unsafe fn unsafe_borrow_io() -> *mut IoFactoryObject {
let sched = Local::unsafe_borrow::<Scheduler>();
let io: *mut IoFactoryObject = (*sched).event_loop.io().unwrap();
return io;
}

View File

@ -67,9 +67,6 @@ pub mod task;
/// The coroutine task scheduler, built on the `io` event loop.
mod sched;
/// Thread-local access to the current Scheduler.
pub mod local_sched;
/// Synchronous I/O.
#[path = "io/mod.rs"]
pub mod io;
@ -189,7 +186,7 @@ pub fn context() -> RuntimeContext {
use task::rt::rust_task;
use self::local::Local;
use self::sched::{local_sched, Scheduler};
use self::sched::Scheduler;
// XXX: Hitting TLS twice to check if the scheduler exists
// then to check for the task is not good for perf
@ -220,7 +217,7 @@ pub fn context() -> RuntimeContext {
#[test]
fn test_context() {
use unstable::run_in_bare_thread;
use self::sched::{local_sched, Scheduler, Coroutine};
use self::sched::{Scheduler, Coroutine};
use rt::uv::uvio::UvEventLoop;
use cell::Cell;
use rt::local::Local;

View File

@ -20,9 +20,7 @@ use super::context::Context;
use super::task::Task;
use rt::local_ptr;
use rt::local::Local;
// A more convenient name for external callers, e.g. `local_sched::take()`
pub mod local_sched;
use rt::rtio::IoFactoryObject;
/// The Scheduler is responsible for coordinating execution of Coroutines
/// on a single thread. When the scheduler is running it is owned by
@ -403,6 +401,12 @@ pub impl Coroutine {
}
}
pub unsafe fn unsafe_borrow_io() -> *mut IoFactoryObject {
let sched = Local::unsafe_borrow::<Scheduler>();
let io: *mut IoFactoryObject = (*sched).event_loop.io().unwrap();
return io;
}
#[cfg(test)]
mod test {
use int;

View File

@ -16,7 +16,7 @@
use prelude::*;
use libc::{c_void, uintptr_t};
use cast::transmute;
use super::sched::{Scheduler, local_sched};
use super::sched::Scheduler;
use rt::local::Local;
use super::local_heap::LocalHeap;
use rt::logging::StdErrLogger;

View File

@ -18,7 +18,6 @@ use clone::Clone;
use super::rc::RC;
use rt::sched::{Scheduler, Coroutine};
use rt::{context, TaskContext, SchedulerContext};
use rt::local_sched;
use rt::local::Local;
use vec::OwnedVector;
use container::Container;
@ -95,7 +94,6 @@ impl<T> Clone for Tube<T> {
mod test {
use int;
use cell::Cell;
use rt::local_sched;
use rt::test::*;
use rt::rtio::EventLoop;
use rt::sched::Scheduler;

View File

@ -19,7 +19,8 @@ use rt::io::net::ip::IpAddr;
use rt::uv::*;
use rt::uv::idle::IdleWatcher;
use rt::rtio::*;
use rt::sched::{Scheduler, local_sched};
use rt::sched::unsafe_borrow_io;
use rt::sched::Scheduler;
use rt::io::{standard_error, OtherIoError};
use rt::tube::Tube;
use rt::local::Local;
@ -358,7 +359,7 @@ impl RtioTcpStream for UvTcpStream {
fn test_simple_io_no_connect() {
do run_in_newsched_task {
unsafe {
let io = local_sched::unsafe_borrow_io();
let io = unsafe_borrow_io();
let addr = next_test_ip4();
let maybe_chan = (*io).tcp_connect(addr);
assert!(maybe_chan.is_err());
@ -374,7 +375,7 @@ fn test_simple_tcp_server_and_client() {
// Start the server first so it's listening when we connect
do spawntask_immediately {
unsafe {
let io = local_sched::unsafe_borrow_io();
let io = unsafe_borrow_io();
let mut listener = (*io).tcp_bind(addr).unwrap();
let mut stream = listener.accept().unwrap();
let mut buf = [0, .. 2048];
@ -389,7 +390,7 @@ fn test_simple_tcp_server_and_client() {
do spawntask_immediately {
unsafe {
let io = local_sched::unsafe_borrow_io();
let io = unsafe_borrow_io();
let mut stream = (*io).tcp_connect(addr).unwrap();
stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
}
@ -403,7 +404,7 @@ fn test_read_and_block() {
let addr = next_test_ip4();
do spawntask_immediately {
let io = unsafe { local_sched::unsafe_borrow_io() };
let io = unsafe { unsafe_borrow_io() };
let mut listener = unsafe { (*io).tcp_bind(addr).unwrap() };
let mut stream = listener.accept().unwrap();
let mut buf = [0, .. 2048];
@ -439,7 +440,7 @@ fn test_read_and_block() {
do spawntask_immediately {
unsafe {
let io = local_sched::unsafe_borrow_io();
let io = unsafe_borrow_io();
let mut stream = (*io).tcp_connect(addr).unwrap();
stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
@ -459,7 +460,7 @@ fn test_read_read_read() {
do spawntask_immediately {
unsafe {
let io = local_sched::unsafe_borrow_io();
let io = unsafe_borrow_io();
let mut listener = (*io).tcp_bind(addr).unwrap();
let mut stream = listener.accept().unwrap();
let buf = [1, .. 2048];
@ -473,7 +474,7 @@ fn test_read_read_read() {
do spawntask_immediately {
unsafe {
let io = local_sched::unsafe_borrow_io();
let io = unsafe_borrow_io();
let mut stream = (*io).tcp_connect(addr).unwrap();
let mut buf = [0, .. 2048];
let mut total_bytes_read = 0;