Port ID-based channels.

This commit is contained in:
Eric Holk 2011-08-09 16:07:49 -07:00
parent 04af99ecb0
commit 39b16077bb
9 changed files with 96 additions and 7 deletions

View file

@ -5,6 +5,7 @@ native "rust" mod rustrt {
fn unsupervise();
fn pin_task();
fn unpin_task();
fn get_task_id() -> task_id;
fn clone_chan(c: *rust_chan) -> *rust_chan;
type rust_chan;
@ -12,6 +13,12 @@ native "rust" mod rustrt {
fn set_min_stack(stack_size: uint);
}
type task_id = int;
fn get_task_id() -> task_id {
rustrt::get_task_id()
}
/**
* Hints the scheduler to yield this task for a specified ammount of time.
*
@ -33,6 +40,7 @@ fn pin() { rustrt::pin_task(); }
fn unpin() { rustrt::unpin_task(); }
// FIXME: remove this
fn clone_chan[T](c: chan[T]) -> chan[T] {
let cloned = rustrt::clone_chan(unsafe::reinterpret_cast(c));
ret unsafe::reinterpret_cast(cloned);