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
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user