Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduler multithreading #6821

Closed
wants to merge 16 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/libcore/rt/mod.rs
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 2 additions & 2 deletions src/libcore/rt/sched.rs
Original file line number Diff line number Diff line change
@@ -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,
3 changes: 2 additions & 1 deletion src/libcore/rt/uv/uvio.rs
Original file line number Diff line number Diff line change
@@ -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())
}
}