2010-08-11 23:23:34 -05:00
|
|
|
native "rust" mod rustrt {
|
2011-07-27 07:19:39 -05:00
|
|
|
fn task_sleep(time_in_us: uint);
|
2011-05-31 19:44:54 -05:00
|
|
|
fn task_yield();
|
2011-07-27 07:19:39 -05:00
|
|
|
fn task_join(t: task) -> int;
|
2011-07-14 22:54:57 -05:00
|
|
|
fn unsupervise();
|
2011-06-29 20:47:47 -05:00
|
|
|
fn pin_task();
|
|
|
|
fn unpin_task();
|
2011-07-27 07:19:39 -05:00
|
|
|
fn clone_chan(c: *rust_chan) -> *rust_chan;
|
2011-07-21 14:11:05 -05:00
|
|
|
|
|
|
|
type rust_chan;
|
2011-07-25 17:02:43 -05:00
|
|
|
|
|
|
|
fn set_min_stack(stack_size: uint);
|
2010-08-11 23:23:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hints the scheduler to yield this task for a specified ammount of time.
|
|
|
|
*
|
|
|
|
* arg: time_in_us maximum number of microseconds to yield control for
|
|
|
|
*/
|
2011-07-27 07:19:39 -05:00
|
|
|
fn sleep(time_in_us: uint) { ret rustrt::task_sleep(time_in_us); }
|
2010-09-22 17:44:13 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn yield() { ret rustrt::task_yield(); }
|
2011-05-31 19:44:54 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
tag task_result { tr_success; tr_failure; }
|
2011-07-14 21:39:53 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn join(t: task) -> task_result {
|
|
|
|
alt rustrt::task_join(t) { 0 { tr_success } _ { tr_failure } }
|
2011-05-31 19:44:54 -05:00
|
|
|
}
|
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn unsupervise() { ret rustrt::unsupervise(); }
|
2011-07-14 19:56:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn pin() { rustrt::pin_task(); }
|
2011-06-29 20:47:47 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn unpin() { rustrt::unpin_task(); }
|
2011-06-29 20:47:47 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn clone_chan[T](c: chan[T]) -> chan[T] {
|
|
|
|
let cloned = rustrt::clone_chan(unsafe::reinterpret_cast(c));
|
2011-07-21 14:11:05 -05:00
|
|
|
ret unsafe::reinterpret_cast(cloned);
|
|
|
|
}
|
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn send[T](c: chan[T], v: &T) { c <| v; }
|
2011-07-24 00:41:28 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn recv[T](p: port[T]) -> T { let v; p |> v; v }
|
2011-07-24 00:41:28 -05:00
|
|
|
|
2011-07-25 17:02:43 -05:00
|
|
|
fn set_min_stack(uint stack_size) {
|
|
|
|
rustrt::set_min_stack(stack_size);
|
|
|
|
}
|
|
|
|
|
2010-09-22 17:44:13 -05:00
|
|
|
// Local Variables:
|
|
|
|
// mode: rust;
|
|
|
|
// fill-column: 78;
|
|
|
|
// indent-tabs-mode: nil
|
|
|
|
// c-basic-offset: 4
|
|
|
|
// buffer-file-coding-system: utf-8-unix
|
2011-06-15 14:01:19 -05:00
|
|
|
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
2010-09-22 17:44:13 -05:00
|
|
|
// End:
|