[src]

Struct green::SchedPool

pub struct SchedPool {
    // some fields omitted
}

A structure representing a handle to a pool of schedulers. This handle is used to keep the pool alive and also reap the status from the pool.

Methods

impl SchedPool

fn new(config: PoolConfig) -> SchedPool

Execute the main function in a pool of M:N schedulers.

This will configure the pool according to the config parameter, and initially run main inside the pool of schedulers.

fn task(&mut self, opts: TaskOpts, f: proc()) -> ~GreenTask

Creates a new task configured to run inside of this pool of schedulers. This is useful to create a task which can then be sent to a specific scheduler created by spawn_sched (and possibly pin it to that scheduler).

fn spawn(&mut self, opts: TaskOpts, f: proc())

Spawns a new task into this pool of schedulers, using the specified options to configure the new task which is spawned.

New tasks are spawned in a round-robin fashion to the schedulers in this pool, but tasks can certainly migrate among schedulers once they're in the pool.

fn spawn_sched(&mut self) -> SchedHandle

Spawns a new scheduler into this M:N pool. A handle is returned to the scheduler for use. The scheduler will not exit as long as this handle is active.

The scheduler spawned will participate in work stealing with all of the other schedulers currently in the scheduler pool.

fn shutdown(self)

Consumes the pool of schedulers, waiting for all tasks to exit and all schedulers to shut down.

This function is required to be called in order to drop a pool of schedulers, it is considered an error to drop a pool without calling this method.

This only waits for all tasks in this pool of schedulers to exit, any native tasks or extern pools will not be waited on

Trait Implementations

impl Drop for SchedPool

fn drop(&mut self)