core::rt: Scheduler takes a WorkQueue
This will be for implementing a work-sharing strategy
This commit is contained in:
parent
41c21685dd
commit
8b7e392752
3 changed files with 7 additions and 4 deletions
|
|
@ -145,12 +145,14 @@ pub mod thread_local_storage;
|
|||
pub fn start(_argc: int, _argv: **u8, crate_map: *u8, main: ~fn()) -> int {
|
||||
|
||||
use self::sched::{Scheduler, Coroutine};
|
||||
use self::work_queue::WorkQueue;
|
||||
use self::uv::uvio::UvEventLoop;
|
||||
|
||||
init(crate_map);
|
||||
|
||||
let loop_ = ~UvEventLoop::new();
|
||||
let mut sched = ~Scheduler::new(loop_);
|
||||
let work_queue = WorkQueue::new();
|
||||
let mut sched = ~Scheduler::new(loop_, work_queue);
|
||||
let main_task = ~Coroutine::new(&mut sched.stack_pool, main);
|
||||
|
||||
sched.enqueue_task(main_task);
|
||||
|
|
|
|||
|
|
@ -65,14 +65,14 @@ pub impl Scheduler {
|
|||
|
||||
fn in_task_context(&self) -> bool { self.current_task.is_some() }
|
||||
|
||||
fn new(event_loop: ~EventLoopObject) -> Scheduler {
|
||||
fn new(event_loop: ~EventLoopObject, work_queue: WorkQueue<~Coroutine>) -> Scheduler {
|
||||
|
||||
// Lazily initialize the runtime TLS key
|
||||
local_ptr::init_tls_key();
|
||||
|
||||
Scheduler {
|
||||
event_loop: event_loop,
|
||||
work_queue: WorkQueue::new(),
|
||||
work_queue: work_queue,
|
||||
stack_pool: StackPool::new(),
|
||||
saved_context: Context::empty(),
|
||||
current_task: None,
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ use rt::sched::Scheduler;
|
|||
use rt::io::{standard_error, OtherIoError};
|
||||
use rt::tube::Tube;
|
||||
use rt::local::Local;
|
||||
use rt::work_queue::WorkQueue;
|
||||
use unstable::sync::{UnsafeAtomicRcBox, AtomicInt};
|
||||
use unstable::intrinsics;
|
||||
|
||||
|
|
@ -45,7 +46,7 @@ pub impl UvEventLoop {
|
|||
|
||||
/// A convenience constructor
|
||||
fn new_scheduler() -> Scheduler {
|
||||
Scheduler::new(~UvEventLoop::new())
|
||||
Scheduler::new(~UvEventLoop::new(), WorkQueue::new())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue