about summary refs log tree commit diff
path: root/src/libstd/task
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-10-29 09:36:47 -0700
committerbors <bors@rust-lang.org>2013-10-29 09:36:47 -0700
commit52f42f16387d0142944f376ea31c554c9caa2189 (patch)
treee6e4d20d5c8d43c280d6c9ba02c063fe1ae11b2c /src/libstd/task
parente6650c87a3800264a043b7f129e6a4841c4cc3f7 (diff)
parent201cab84e8f12ec73131ac4908e6779b277449a2 (diff)
downloadrust-52f42f16387d0142944f376ea31c554c9caa2189.tar.gz
rust-52f42f16387d0142944f376ea31c554c9caa2189.zip
auto merge of #10058 : alexcrichton/rust/uv-crate, r=brson
This is one of the final steps needed to complete #9128. It still needs a little bit of polish before closing that issue, but it's in a pretty much "done" state now.

The idea here is that the entire event loop implementation using libuv is now housed in `librustuv` as a completely separate library. This library is then injected (via `extern mod rustv`) into executable builds (similarly to how libstd is injected, tunable via `#[no_uv]`) to bring in the "rust blessed event loop implementation."

Codegen-wise, there is a new `event_loop_factory` language item which is tagged on a function with 0 arguments returning `~EventLoop`. This function's symbol is then inserted into the crate map for an executable crate, and if there is no definition of the `event_loop_factory` language item then the value is null.

What this means is that embedding rust as a library in another language just got a little harder. Libraries don't have crate maps, which means that there's no way to find the event loop implementation to spin up the runtime. That being said, it's always possible to build the runtime manually. This request also makes more runtime components public which should probably be public anyway. This new public-ness should allow custom scheduler setups everywhere regardless of whether you follow the `rt::start `path.
Diffstat (limited to 'src/libstd/task')
-rw-r--r--src/libstd/task/mod.rs4
-rw-r--r--src/libstd/task/spawn.rs14
2 files changed, 9 insertions, 9 deletions
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..a08bf8f3147 100644
--- a/src/libstd/task/spawn.rs
+++ b/src/libstd/task/spawn.rs
@@ -80,13 +80,14 @@ use comm::{Chan, GenericChan, oneshot};
 use container::MutableMap;
 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, Shutdown, TaskFromFriend};
 use rt::task::{Task, Sched};
 use rt::task::{UnwindReasonLinked, UnwindReasonStr};
 use rt::task::{UnwindResult, Success, Failure};
-use rt::uv::uvio::UvEventLoop;
+use rt::thread::Thread;
+use rt::work_queue::WorkQueue;
+use rt::{in_green_task_context, new_event_loop, KillHandle};
 use send_str::IntoSendStr;
 use task::SingleThreaded;
 use task::TaskOpts;
@@ -617,8 +618,7 @@ pub fn spawn_raw(mut opts: TaskOpts, f: ~fn()) {
             let work_queue = WorkQueue::new();
 
             // Create a new scheduler to hold the new task
-            let new_loop = ~UvEventLoop::new() as ~EventLoop;
-            let mut new_sched = ~Scheduler::new_special(new_loop,
+            let mut new_sched = ~Scheduler::new_special(new_event_loop(),
                                                         work_queue,
                                                         (*sched).work_queues.clone(),
                                                         (*sched).sleeper_list.clone(),
@@ -627,7 +627,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 +665,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