diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index eaaf8c43281..21fdf0e50a1 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -87,15 +87,13 @@ pub use self::util::set_exit_status; // method... pub use self::util::default_sched_threads; +// Re-export of the functionality in the kill module +pub use self::kill::{KillHandle, BlockedTask}; + // XXX: these probably shouldn't be public... #[doc(hidden)] pub mod shouldnt_be_public { - pub use super::sched::Scheduler; - pub use super::kill::KillHandle; - pub use super::thread::Thread; - pub use super::work_queue::WorkQueue; pub use super::select::SelectInner; - pub use super::rtio::EventLoop; pub use super::select::{SelectInner, SelectPortInner}; pub use super::local_ptr::maybe_tls_key; } @@ -116,13 +114,13 @@ pub mod task; mod kill; /// The coroutine task scheduler, built on the `io` event loop. -mod sched; +pub mod sched; /// Synchronous I/O. pub mod io; /// The EventLoop and internal synchronous I/O interface. -mod rtio; +pub mod rtio; /// libuv and default rtio implementation. pub mod uv; @@ -132,10 +130,10 @@ pub mod uv; pub mod local; /// A parallel work-stealing deque. -mod work_queue; +pub mod work_queue; /// A parallel queue. -mod message_queue; +pub mod message_queue; /// A mostly lock-free multi-producer, single consumer queue. mod mpsc_queue; @@ -144,7 +142,7 @@ mod mpsc_queue; mod mpmc_bounded_queue; /// A parallel data structure for tracking sleeping schedulers. -mod sleeper_list; +pub mod sleeper_list; /// Stack segments and caching. pub mod stack; @@ -153,7 +151,7 @@ pub mod stack; mod context; /// Bindings to system threading libraries. -mod thread; +pub mod thread; /// The runtime configuration, read from environment variables. pub mod env; @@ -327,7 +325,7 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int { // waking up schedulers for work stealing; since this is a // non-work-stealing scheduler it should not be adding itself // to the list. - main_handle.send_shutdown(); + main_handle.send(Shutdown); Some(main_sched) } else { None diff --git a/src/libstd/rt/sched.rs b/src/libstd/rt/sched.rs index d44264befc1..3ee822ced2d 100644 --- a/src/libstd/rt/sched.rs +++ b/src/libstd/rt/sched.rs @@ -542,7 +542,7 @@ impl Scheduler { match this.sleeper_list.casual_pop() { Some(handle) => { - let mut handle = handle; + let mut handle = handle; handle.send(Wake) } None => { (/* pass */) } @@ -818,12 +818,6 @@ impl SchedHandle { self.queue.push(msg); self.remote.fire(); } - pub fn send_task_from_friend(&mut self, friend: ~Task) { - self.send(TaskFromFriend(friend)); - } - pub fn send_shutdown(&mut self) { - self.send(Shutdown); - } } struct CleanupJob { @@ -1266,15 +1260,15 @@ mod test { use comm::{GenericPort, GenericChan}; do run_in_mt_newsched_task { - let (end_port, end_chan) = oneshot(); + let (end_port, end_chan) = oneshot(); let n_tasks = 10; let token = 2000; - let (p, ch1) = stream(); + let (p, ch1) = stream(); let mut p = p; - ch1.send((token, end_chan)); - let mut i = 2; + ch1.send((token, end_chan)); + let mut i = 2; while i <= n_tasks { let (next_p, ch) = stream(); let imm_i = i; diff --git a/src/libstd/select.rs b/src/libstd/select.rs index 75b09187f04..f5dc98c57b6 100644 --- a/src/libstd/select.rs +++ b/src/libstd/select.rs @@ -18,7 +18,9 @@ use option::*; // use either::{Either, Left, Right}; // use rt::kill::BlockedTask; use rt::local::Local; -use rt::shouldnt_be_public::{EventLoop, Scheduler, SelectInner, SelectPortInner}; +use rt::rtio::EventLoop; +use rt::sched::Scheduler; +use rt::shouldnt_be_public::{SelectInner, SelectPortInner}; use task; use unstable::finally::Finally; use vec::{OwnedVector, MutableVector}; diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs index 8efa185bbbd..023ba6f7108 100644 --- a/src/libstd/task/mod.rs +++ b/src/libstd/task/mod.rs @@ -578,7 +578,7 @@ pub fn deschedule() { //! Yield control to the task scheduler use rt::local::Local; - use rt::shouldnt_be_public::Scheduler; + use rt::sched::Scheduler; // FIXME(#7544): Optimize this, since we know we won't block. let sched: ~Scheduler = Local::take(); @@ -1094,7 +1094,7 @@ fn test_try_fail() { #[cfg(test)] fn get_sched_id() -> int { - do Local::borrow |sched: &mut ::rt::shouldnt_be_public::Scheduler| { + do Local::borrow |sched: &mut ::rt::sched::Scheduler| { sched.sched_id() as int } } diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs index 235e67048f6..2cda38f8a30 100644 --- a/src/libstd/task/spawn.rs +++ b/src/libstd/task/spawn.rs @@ -82,7 +82,11 @@ use hashmap::{HashSet, HashSetMoveIterator}; use local_data; use rt::in_green_task_context; use rt::local::Local; -use rt::shouldnt_be_public::{Scheduler, KillHandle, WorkQueue, Thread, EventLoop}; +use rt::sched::Scheduler; +use rt::KillHandle; +use rt::work_queue::WorkQueue; +use rt::rtio::EventLoop; +use rt::thread::Thread; use rt::task::{Task, Sched}; use rt::task::{UnwindReasonLinked, UnwindReasonStr}; use rt::task::{UnwindResult, Success, Failure}; @@ -627,7 +631,7 @@ pub fn spawn_raw(mut opts: TaskOpts, f: ~fn()) { let mut new_sched_handle = new_sched.make_handle(); // Allow the scheduler to exit when the pinned task exits - new_sched_handle.send_shutdown(); + new_sched_handle.send(Shutdown); // Pin the new task to the new scheduler let new_task = if opts.watched { @@ -665,7 +669,7 @@ pub fn spawn_raw(mut opts: TaskOpts, f: ~fn()) { debug!("enqueing join_task"); // Now tell the original scheduler to join with this thread // by scheduling a thread-joining task on the original scheduler - orig_sched_handle.send_task_from_friend(join_task); + orig_sched_handle.send(TaskFromFriend(join_task)); // NB: We can't simply send a message from here to another task // because this code isn't running in a task and message passing doesn't diff --git a/src/libstd/unstable/mod.rs b/src/libstd/unstable/mod.rs index 835b16996b5..484ddde6d3c 100644 --- a/src/libstd/unstable/mod.rs +++ b/src/libstd/unstable/mod.rs @@ -37,7 +37,7 @@ a normal large stack. */ pub fn run_in_bare_thread(f: ~fn()) { use cell::Cell; - use rt::shouldnt_be_public::Thread; + use rt::thread::Thread; let f_cell = Cell::new(f); let (port, chan) = comm::stream();