IScheduler

Scheduler handles concurrent execution of all application tasks, assigning them to limited amount of worker fibers. Scheduler functionality can be split into 3 major blocks:

1. executing arbitrary ocean.task.Task using a worker fiber from a pool 2. keeping queue of tasks to execute in cases when all worker fibers are busy 3. allowing any task to suspend to allow event processing by epoll in a way that it will be automatically resumed by scheduler again when there are no more immediate pending events

Members

Functions

await
void await(Task task, void delegate(Task) finished_dg)

Schedules the argument and suspends calling task until the argument finishes.

awaitOrTimeout
bool awaitOrTimeout(Task task, uint micro_seconds)

Similar to await but also has waiting timeout. Calling task will be resumed either if awaited task finished or timeout is hit, whichever happens first.

awaitResult
typeof(TaskT.result) awaitResult(TaskT task)

Convenience shortcut on top of await to await for a task and return some value type as a result.

delayedResume
void delayedResume(Task task)

Orders scheduler to resume given task unconditionally after current epoll cycle. Must be used instead of plain Task.resume from termination hooks of other tasks.

epoll
EpollSelectDispatcher epoll()

Getter for scheduler epoll instance. Necessary for integration with ISelectClient utilities so that new select client can be registered.

eventLoop
void eventLoop()

Starts pseudo-infinite event loop. Event loop will keep running as long as there is at least one event registered.

getSpecializedPoolStats
Optional!(SpecializedPoolStats) getSpecializedPoolStats(cstring name)
getStats
Stats getStats()

Provides load stats for the scheduler

processEvents
void processEvents()

Suspends current fiber temporarily, allowing pending events to be processed. Current fiber will be resumed as soon as no immediate events are left.

queue
void queue(Task task)

Method used to queue the task for later execution.

schedule
void schedule(Task task)

Method used to execute new task.

shutdown
void shutdown()

Forces early termination of all active tasks and shuts down event loop.

Structs

Configuration
struct Configuration

Aggregation of various size limits used internally by scheduler. Instance of this struct is used as initScheduler argument.

SpecializedPoolStats
struct SpecializedPoolStats

Usage stats of a single specialized task pool

Stats
struct Stats

Aggregate of various statistics that indicate overall scheduler load and performance.

Meta