Struct green::task::GreenTask[src]
pub struct GreenTask {
pub coroutine: Option<Coroutine>,
pub handle: Option<SchedHandle>,
pub sched: Option<Box<Scheduler>>,
pub task: Option<Box<Task>>,
pub task_type: TaskType,
pub pool_id: uint,
pub nasty_deschedule_lock: NativeMutex,
}The necessary fields needed to keep track of a green task (as opposed to a 1:1 task).
Fields
coroutine | Coroutine that this task is running on, otherwise known as the register context and the stack that this task owns. This field is optional to relinquish ownership back to a scheduler to recycle stacks at a later date. |
handle | Optional handle back into the home sched pool of this task. This field is lazily initialized. |
sched | Slot for maintaining ownership of a scheduler. If a task is running, this value will be Some(sched) where the task is running on "sched". |
task | Temporary ownership slot of a std::rt::task::Task object. This is used to squirrel that libstd task away while we're performing green task operations. |
task_type | Dictates whether this is a sched task or a normal green task |
pool_id | Home pool that this task was spawned into. This field is lazily initialized until when the task is initially scheduled, and is used to make sure that tasks are always woken up in the correct pool of schedulers. |
nasty_deschedule_lock |
Methods
impl GreenTask
fn new(stack_pool: &mut StackPool, stack_size: Option<uint>, start: proc(): Send) -> Box<GreenTask>
Creates a new green task which is not homed to any particular scheduler and will not have any contained Task structure.
fn new_homed(stack_pool: &mut StackPool, stack_size: Option<uint>, home: Home, start: proc(): Send) -> Box<GreenTask>
Creates a new task (like new), but specifies the home for new task.
fn new_typed(coroutine: Option<Coroutine>, task_type: TaskType) -> Box<GreenTask>
Creates a new green task with the specified coroutine and type, this is useful when creating scheduler tasks.
fn configure(pool: &mut StackPool, opts: TaskOpts, f: proc(): Send) -> Box<GreenTask>
Creates a new green task with the given configuration options for the contained Task object. The given stack pool is also used to allocate a new stack for this task.
fn convert(task: Box<Task>) -> Box<GreenTask>
Just like the maybe_take_runtime function, this function should not
exist. Usage of this function is strongly discouraged. This is an
absolute last resort necessary for converting a libstd task to a green
task.
This function will assert that the task is indeed a green task before returning (and will kill the entire process if this is wrong).