about summary refs log tree commit diff
path: root/src/libstd/task
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-10-22 15:13:18 -0700
committerAlex Crichton <alex@alexcrichton.com>2013-10-29 08:39:22 -0700
commit201cab84e8f12ec73131ac4908e6779b277449a2 (patch)
tree2312f91c2280a1463c179753fe6123b27a77ae9e /src/libstd/task
parent5dd1583c57fbee9a07ac1111858871c241a24c50 (diff)
downloadrust-201cab84e8f12ec73131ac4908e6779b277449a2.tar.gz
rust-201cab84e8f12ec73131ac4908e6779b277449a2.zip
Move rust's uv implementation to its own crate
There are a few reasons that this is a desirable move to take:

1. Proof of concept that a third party event loop is possible
2. Clear separation of responsibility between rt::io and the uv-backend
3. Enforce in the future that the event loop is "pluggable" and replacable

Here's a quick summary of the points of this pull request which make this
possible:

* Two new lang items were introduced: event_loop, and event_loop_factory.
  The idea of a "factory" is to define a function which can be called with no
  arguments and will return the new event loop as a trait object. This factory
  is emitted to the crate map when building an executable. The factory doesn't
  have to exist, and when it doesn't then an empty slot is in the crate map and
  a basic event loop with no I/O support is provided to the runtime.

* When building an executable, then the rustuv crate will be linked by default
  (providing a default implementation of the event loop) via a similar method to
  injecting a dependency on libstd. This is currently the only location where
  the rustuv crate is ever linked.

* There is a new #[no_uv] attribute (implied by #[no_std]) which denies
  implicitly linking to rustuv by default

Closes #5019
Diffstat (limited to 'src/libstd/task')
-rw-r--r--src/libstd/task/spawn.rs14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs
index 2cda38f8a30..a08bf8f3147 100644
--- a/src/libstd/task/spawn.rs
+++ b/src/libstd/task/spawn.rs
@@ -80,17 +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::sched::Scheduler;
-use rt::KillHandle;
-use rt::work_queue::WorkQueue;
-use rt::rtio::EventLoop;
-use rt::thread::Thread;
+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;
@@ -621,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(),