]> git.lizzy.rs Git - rust.git/commitdiff
Make some more rt components public
authorAlex Crichton <alex@alexcrichton.com>
Tue, 22 Oct 2013 22:09:23 +0000 (15:09 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 28 Oct 2013 20:14:42 +0000 (13:14 -0700)
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.

src/libstd/rt/mod.rs
src/libstd/rt/sched.rs
src/libstd/select.rs
src/libstd/task/mod.rs
src/libstd/task/spawn.rs
src/libstd/unstable/mod.rs

index eaaf8c4328191655204e2cd4f6539392f5f23a70..21fdf0e50a1128e52fc871056511b8cbcc0c3754 100644 (file)
 // 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 shouldnt_be_public {
 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 shouldnt_be_public {
 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 @@ pub mod shouldnt_be_public {
 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 shouldnt_be_public {
 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
index d44264befc16f0938e81607d08166f1fef17a663..3ee822ced2dd4e3e60f42a4456494899409fac33 100644 (file)
@@ -542,7 +542,7 @@ pub fn enqueue_task(&mut self, task: ~Task) {
 
         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 @@ pub fn send(&mut self, msg: SchedMessage) {
         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 @@ fn thread_ring() {
         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;
index 75b09187f04ccfb47aa3806436bf2ea029a7430c..f5dc98c57b65187bb712ddb716161930f495787e 100644 (file)
@@ -18,7 +18,9 @@
 // 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};
index 8efa185bbbdd10f3637e9661fe36819b030a881b..023ba6f7108a23a16ffd8f90e7eb2bc72e45fc5f 100644 (file)
@@ -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
     }
 }
index 235e67048f678738cfd63c5a037ee070594b6c23..2cda38f8a30baf18e18b83106e9c0642965e9f96 100644 (file)
 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
index 835b16996b5f27deede094122f2935354e09989c..484ddde6d3ccd226b6dcebee2b6ec900f2e6cc8d 100644 (file)
@@ -37,7 +37,7 @@
 */
 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();