Reactor

The main scheduler for the micro-threading architecture.

struct Reactor {}

Postblit

this(this)
this(this)
Undocumented in source.

Members

Aliases

IdleCallbackDlg
alias IdleCallbackDlg = bool delegate(Duration)

Delegates passed to registerIdleCallback must be of this signature

Functions

LOG_TRACEBACK_AS
void LOG_TRACEBACK_AS(FiberHandle fh, string text, string file, size_t line)

Log the stack trace of a given fiber.

assertMayContextSwitch
void assertMayContextSwitch(string message)

Make sure we are allowed to context switch from this point.

boostFiberPriority
auto boostFiberPriority()

Give a fiber temporary priority in execution.

call
TimerHandle call(Parameters!F params)
TimerHandle call(T dg)

Schedule a callback for out of bounds immediate execution.

considerYield
bool considerYield(uint tolerance)

Perform yield if fiber is running long enough.

deferToThread
auto deferToThread(Parameters!F args, Timeout timeout)
auto deferToThread(F dlg, Timeout timeout)

run a function inside a different thread.

enterCriticalSection
void enterCriticalSection()

enter a no-fiber switch piece of code.

getFiberName
string getFiberName(FiberHandle fh)
string getFiberName()

Retrieve the fiber name set by setFiberName

getFiberPtr
void* getFiberPtr(FiberHandle fh)
void* getFiberPtr()

Retrieve the fiber pointer set by setFiberName

getFiberState
FiberState getFiberState(FiberHandle fh)

Returns the FiberState of the specified fiber.

iterateFibers
auto iterateFibers()

Iterate all fibers

iterateScheduledFibers
auto iterateScheduledFibers(FiberPriorities priority)
Undocumented in source. Be warned that the author may not have intended to support it.
joinFiber
void joinFiber(FiberHandle fh, Timeout timeout)

Wait until given fiber finishes

leaveCriticalSection
void leaveCriticalSection()

leave the innermost critical section.

pushFiberName
auto pushFiberName(string name, void* ptr)
auto pushFiberName(string name, T dlg)

Temporarily change the fiber's name

registerIdleCallback
void registerIdleCallback(IdleCallbackDlg dg)

Register an idle handler callback.

registerRecurringTimer
TimerHandle registerRecurringTimer(Duration interval, void delegate() dg)
TimerHandle registerRecurringTimer(Duration interval, Parameters!F params)
TimerHandle registerRecurringTimer(Duration interval, void delegate() dg, Timeout firstRun)
TimerHandle registerRecurringTimer(Duration interval, Parameters!F params, Timeout firstRun)

registers a timer that will repeatedly trigger at set intervals.

registerTimer
TimerHandle registerTimer(Timeout timeout, Parameters!F params)
TimerHandle registerTimer(Duration timeout, Parameters!F params)

Registers a timer task.

registerTimer
TimerHandle registerTimer(Timeout timeout, T dg)
TimerHandle registerTimer(Duration timeout, T dg)

Register a timer callback

requestGCCollection
void requestGCCollection(bool waitForCollection)

Request that a GC collection take place ASAP

resumeFiber
void resumeFiber(FiberHandle handle, bool priority)

Resume a suspended fiber

setFiberName
void setFiberName(FiberHandle fh, string name, void* ptr)
void setFiberName(FiberHandle fh, string name, T dlg)

Set a fiber name

setup
void setup(OpenOptions options)

Set the reactor up for doing work.

shouldYield
bool shouldYield(uint tolerance)

Returns whether the fiber is already running for a long time.

sleep
void sleep(Duration duration)
void sleep(Timeout until)

Suspend the current fiber for a specified amount of time

spawnFiber
FiberHandle spawnFiber(T args)

Spawn a new fiber for execution.

spawnFiber
FiberHandle spawnFiber(Parameters!F args)

Spawn a new fiber for execution.

start
int start()

Starts up the reactor.

stop
void stop(int reactorReturn)

Stop the reactor, killing all fibers.

suspendCurrentFiber
void suspendCurrentFiber(Timeout timeout)
void suspendCurrentFiber()

Suspend the current fiber

teardown
void teardown()

Shut the reactor down.

throwInFiber
bool throwInFiber(FiberHandle fHandle, Throwable ex)
bool throwInFiber(FiberHandle fHandle, A args)

forward an exception to another fiber

utThreadPool
auto ref utThreadPool()
Undocumented in source. Be warned that the author may not have intended to support it.
yield
void yield()

Temporarily surrender the CPU for other fibers to run.

Manifest constants

UT_MAX_DEFERRED_TASKS
enum UT_MAX_DEFERRED_TASKS;
Undocumented in source.

Properties

criticalSection
auto criticalSection [@property getter]

Return a RAII object handling a critical section

currentFiberHandle
FiberHandle currentFiberHandle [@property getter]

Returns a FiberHandle to the currently running fiber

currentFiberId
FiberId currentFiberId [@property getter]

Returns the FiberId of the currently running fiber.

currentFiberPtr
ReactorFiber* currentFiberPtr [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
hangDetectorEnabled
bool hangDetectorEnabled [@property getter]
bool hangDetectorEnabled [@property setter]

Property for disabling/enabling the hang detector.

isActive
bool isActive [@property getter]

Report whether the reactor is currently active

isIdle
bool isIdle [@property getter]

Returns whether currently running fiber is the idle fiber.

isInCriticalSection
bool isInCriticalSection [@property getter]

Reports whether execution is currently within a critical section

isMain
bool isMain [@property getter]

Returns whether currently running fiber is the main fiber.

isOpen
bool isOpen [@property getter]

Report whether the reactor has been properly opened (i.e. - setup has been called).

isRunning
bool isRunning [@property getter]

Report whether the reactor is currently running

isSpecialFiber
bool isSpecialFiber [@property getter]

Returns whether currently running fiber is a special (i.e. - non-user) fiber

reactorStats
Stats reactorStats [@property getter]

Report the current reactor statistics.

thisFiber
inout(ReactorFiber)* thisFiber [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Structs

OpenOptions
struct OpenOptions

The options control aspects of the reactor's operation

Stats
struct Stats

Used by reportStats to report statistics about the reactor

TimerHandle
struct TimerHandle

Handle used to manage registered timers

Meta