Make some more rt components public
Primarily this makes the Scheduler and all of its related interfaces public. The reason for doing this is that currently any extern event loops had no access to the scheduler at all. This allows third-party event loops to manipulate the scheduler, along with allowing the uv event loop to live inside of its own crate.
This commit is contained in:
parent
2ab4a6fab0
commit
5dd1583c57
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue