FiberScheduler

An example Scheduler using Fibers.

This is an example scheduler that creates a new Fiber per call to spawn and multiplexes the execution of all fibers within the main thread.

Members

Classes

FiberBinarySemaphore
class FiberBinarySemaphore
Undocumented in source.
InfoFiber
class InfoFiber

Fiber which embeds a ThreadInfo

Functions

create
void create(void delegate() op)

Creates a new Fiber which calls the given delegate.

schedule
void schedule(void delegate() op)

Schedule a task to be run next time the scheduler yields

spawn
void spawn(void delegate() op)

This created a new Fiber for the supplied op and adds it to the dispatch list.

start
void start(void delegate() op)

This creates a new Fiber for the supplied op and then starts the dispatcher.

Properties

thisInfo
ThreadInfo thisInfo [@property getter]

Returns an appropriate ThreadInfo instance.

Static functions

yield
void yield()

If the caller is a scheduled Fiber, this yields execution to another scheduled Fiber.

Examples

Ensure argument to start is run first

{
    scope sched = new FiberScheduler();
    bool startHasRun;
    sched.spawn(() => assert(startHasRun));
    sched.start(() { startHasRun = true; });
}
{
    scope sched = new FiberScheduler();
    bool startHasRun;
    sched.schedule(() => assert(startHasRun));
    sched.start(() { startHasRun = true; });
}

Meta