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).

fn give_home(&mut self, new_home: Home)

fn take_unwrap_home(&mut self) -> Home

fn is_home_no_tls(&self, sched: &Scheduler) -> bool

fn homed(&self) -> bool

fn is_sched(&self) -> bool

fn as_uint(&self) -> uint

unsafe fn from_uint(val: uint) -> Box<GreenTask>

fn put_with_sched(~self, sched: Box<Scheduler>)

fn put_task(&mut self, task: Box<Task>)

fn swap(~self) -> Box<Task>

fn put(~self)

Trait Implementations

impl Runtime for GreenTask

fn yield_now(~self, cur_task: Box<Task>)

fn maybe_yield(~self, cur_task: Box<Task>)

fn deschedule(~self, times: uint, cur_task: Box<Task>, f: |BlockedTask| -> Result<(), BlockedTask>)

fn reawaken(~self, to_wake: Box<Task>)

fn spawn_sibling(~self, cur_task: Box<Task>, opts: TaskOpts, f: proc(): Send)

fn local_io<'a>(&'a mut self) -> Option<LocalIo<'a>>

fn stack_bounds(&self) -> (uint, uint)

fn can_block(&self) -> bool

fn wrap(~self) -> Box<Any>