2010-08-11 21:23:34 -07:00
|
|
|
native "rust" mod rustrt {
|
2011-07-27 14:19:39 +02:00
|
|
|
fn task_sleep(time_in_us: uint);
|
2011-05-31 17:44:54 -07:00
|
|
|
fn task_yield();
|
2011-07-27 14:19:39 +02:00
|
|
|
fn task_join(t: task) -> int;
|
2011-07-14 20:54:57 -07:00
|
|
|
fn unsupervise();
|
2011-06-29 18:47:47 -07:00
|
|
|
fn pin_task();
|
|
|
|
fn unpin_task();
|
2011-07-27 14:19:39 +02:00
|
|
|
fn clone_chan(c: *rust_chan) -> *rust_chan;
|
2011-07-21 12:11:05 -07:00
|
|
|
|
|
|
|
type rust_chan;
|
2011-07-25 15:02:43 -07:00
|
|
|
|
|
|
|
fn set_min_stack(stack_size: uint);
|
2010-08-11 21:23:34 -07: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 14:19:39 +02:00
|
|
|
fn sleep(time_in_us: uint) { ret rustrt::task_sleep(time_in_us); }
|
2010-09-22 15:44:13 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn yield() { ret rustrt::task_yield(); }
|
2011-05-31 17:44:54 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
tag task_result { tr_success; tr_failure; }
|
2011-07-14 19:39:53 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn join(t: task) -> task_result {
|
|
|
|
alt rustrt::task_join(t) { 0 { tr_success } _ { tr_failure } }
|
2011-05-31 17:44:54 -07:00
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn unsupervise() { ret rustrt::unsupervise(); }
|
2011-07-14 17:56:59 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn pin() { rustrt::pin_task(); }
|
2011-06-29 18:47:47 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn unpin() { rustrt::unpin_task(); }
|
2011-06-29 18:47:47 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn clone_chan[T](c: chan[T]) -> chan[T] {
|
|
|
|
let cloned = rustrt::clone_chan(unsafe::reinterpret_cast(c));
|
2011-07-21 12:11:05 -07:00
|
|
|
ret unsafe::reinterpret_cast(cloned);
|
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn send[T](c: chan[T], v: &T) { c <| v; }
|
2011-07-23 22:41:28 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn recv[T](p: port[T]) -> T { let v; p |> v; v }
|
2011-07-23 22:41:28 -07:00
|
|
|
|
2011-07-28 10:41:48 -07:00
|
|
|
fn set_min_stack(stack_size : uint) {
|
2011-07-25 15:02:43 -07:00
|
|
|
rustrt::set_min_stack(stack_size);
|
|
|
|
}
|
|
|
|
|
2010-09-22 15:44:13 -07: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 12:01:19 -07:00
|
|
|
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
2010-09-22 15:44:13 -07:00
|
|
|
// End:
|