use result;
use rt::{context, OldTaskContext, TaskContext};
use rt::local::Local;
-use task::rt::task_id;
use unstable::finally::Finally;
use util;
pub mod rt;
pub mod spawn;
-/// A handle to a task
-#[deriving(Eq)]
-pub enum Task {
- TaskHandle(task_id)
-}
-
/**
* Indicates the manner in which a task exited.
*
}
}
-pub fn get_task() -> Task {
- //! Get a handle to the running task
-
- unsafe {
- TaskHandle(rt::get_task_id())
- }
-}
-
/**
* Temporarily make the task unkillable
*
// Test that we use fully-qualified type names in error messages.
-use std::task::Task;
+use std::option::Option;
-fn bar(x: uint) -> Task {
+fn bar(x: uint) -> Option<uint> {
return x;
- //~^ ERROR mismatched types: expected `std::task::Task`
+ //~^ ERROR mismatched types: expected `std::option::Option<uint>`
}
fn main() {
use std::util;
+pub type Task = int;
+
// tjc: I don't know why
pub mod pipes {
+ use super::Task;
use std::cast::{forget, transmute};
use std::cast;
use std::task;
pub struct Stuff<T> {
state: state,
- blocked_task: Option<task::Task>,
+ blocked_task: Option<Task>,
payload: Option<T>
}
pub struct packet<T> {
state: state,
- blocked_task: Option<task::Task>,
+ blocked_task: Option<Task>,
payload: Option<T>
}
unsafe {
let p: *packet<T> = cast::transmute(~Stuff{
state: empty,
- blocked_task: None::<task::Task>,
+ blocked_task: None::<Task>,
payload: None::<T>
});
p
fn drop(&self) {
unsafe {
error!("notify: task=%? v=%x unwinding=%b b=%b",
- task::get_task(),
+ 0,
ptr::to_unsafe_ptr(&(*(self.v))) as uint,
task::failing(),
*(self.v));
fn wrapper(c: Chan<bool>, f: &fn()) {
let b = @mut false;
error!("wrapper: task=%? allocated v=%x",
- task::get_task(),
+ 0,
ptr::to_unsafe_ptr(&(*b)) as uint);
let _r = notify(c, b);
f();
// Yield to make sure the supervisor joins before we
// fail. This is currently not needed because the supervisor
// runs first, but I can imagine that changing.
- error!("supervised task=%?", task::get_task);
+ error!("supervised task=%?", 0);
task::yield();
fail!();
}
fn supervisor() {
- error!("supervisor task=%?", task::get_task());
+ error!("supervisor task=%?", 0);
let t = joinable(supervised);
join(t);
}