Struct rustrt::task::TaskExperimental [-]  [+] [src]

pub struct Task {
    pub storage: LocalStorage,
    pub unwinder: Unwinder,
    pub death: Death,
    pub name: Option<SendStr>,
    // some fields omitted
}

State associated with Rust tasks.

This structure is currently undergoing major changes, and is likely to be move/be merged with a Thread structure.

Fields

storage
unwinder
death
name

Methods

impl Task

fn new(stack_bounds: Option<(uint, uint)>, stack_guard: Option<uint>) -> Task

Creates a new uninitialized task.

fn spawn(opts: TaskOpts, f: proc(): Send)

fn run(self: Box<Task>, f: ||) -> Box<Task>

Consumes ownership of a task, runs some code, and returns the task back.

This function can be used as an emulated "try/catch" to interoperate with the rust runtime at the outermost boundary. It is not possible to use this function in a nested fashion (a try/catch inside of another try/catch). Invoking this function is quite cheap.

If the closure f succeeds, then the returned task can be used again for another invocation of run. If the closure f panics then self will be internally destroyed along with all of the other associated resources of this task. The on_exit callback is invoked with the cause of panic (not returned here). This can be discovered by querying is_destroyed().

Note that it is possible to view partial execution of the closure f because it is not guaranteed to run to completion, but this function is guaranteed to return if it panicks. Care should be taken to ensure that stack references made by f are handled appropriately.

It is invalid to call this function with a task that has been previously destroyed via a failed call to run.

fn destroy(self: Box<Task>) -> Box<Task>

Destroy all associated resources of this task.

This function will perform any necessary clean up to prepare the task for destruction. It is required that this is called before a Task falls out of scope.

The returned task cannot be used for running any more code, but it may be used to extract the runtime as necessary.

fn is_destroyed(&self) -> bool

Queries whether this can be destroyed or not.

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

Deschedules the current task, invoking f amt times. It is not recommended to use this function directly, but rather communication primitives in std::comm should be used.

fn reawaken(self: Box<Task>)

Wakes up a previously blocked task. This function can only be called on tasks that were previously blocked in deschedule.

fn yield_now()

Yields control of this task to another task. This function will eventually return, but possibly not immediately. This is used as an opportunity to allow other tasks a chance to run.

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

Returns the stack bounds for this task in (lo, hi) format. The stack bounds may not be known for all tasks, so the return value may be None.

fn stack_guard(&self) -> Option<uint>

Returns the stack guard for this task, if known.

fn drop(self)

Consume this task, flagging it as a candidate for destruction.

This function is required to be invoked to destroy a task. A task destroyed through a normal drop will abort.

Trait Implementations

impl Local<Borrowed<Task>> for Task

fn put(value: Box<Task>)

fn take() -> Box<Task>

fn try_take() -> Option<Box<Task>>

fn exists(_: Option<Task>) -> bool

fn borrow(_: Option<Task>) -> Borrowed<Task>

unsafe fn unsafe_take() -> Box<Task>

unsafe fn unsafe_borrow() -> *mut Task

unsafe fn try_unsafe_borrow() -> Option<*mut Task>

impl Drop for Task

fn drop(&mut self)