Struct Reactor

The main scheduler for the micro-threading architecture.

struct Reactor ;

Properties

NameTypeDescription
currentFiberHandle[get] FiberHandleReturns a FiberHandle to the currently running fiber
currentFiberId[get] mecca.lib.typedid.RawTypedIdentifier!("FiberId",ushort,65535,65535,mecca.log.FMT("0x{_value!%04X}"),false)Returns the FiberId of the currently running fiber.
hangDetectorEnabled[get, set] boolProperty for disabling/enabling the hang detector.
isActive[get] boolReport whether the reactor is currently active
isIdle[get] boolReturns whether currently running fiber is the idle fiber.
isInCriticalSection[get] boolReports whether execution is currently within a critical section
isMain[get] boolReturns whether currently running fiber is the main fiber.
isOpen[get] boolReport whether the reactor has been properly opened (i.e. - setup has been called).
isRunning[get] boolReport whether the reactor is currently running
isSpecialFiber[get] boolReturns whether currently running fiber is a special (i.e. - non-user) fiber
reactorStats[get] Reactor.StatsReport the current reactor statistics.

Methods

NameDescription
assertMayContextSwitch Make sure we are allowed to context switch from this point.
boostFiberPriority Give a fiber temporary priority in execution.
call Schedule a callback for out of bounds immediate execution.
considerYield Perform yield if fiber is running long enough.
criticalSection Return a RAII object handling a critical section
deferToThread run a function inside a different thread.
dontYield Don't yield
enterCriticalSection enter a no-fiber switch piece of code.
getFiberName Retrieve the fiber name set by setFiberName
getFiberPtr Retrieve the fiber pointer set by setFiberName
getFiberState Returns the FiberState of the specified fiber.
iterateFibers Iterate all fibers
joinFiber Wait until given fiber finishes
leaveCriticalSection leave the innermost critical section.
LOG_TRACEBACK_AS Log the stack trace of a given fiber.
pushFiberName Temporarily change the fiber's name
registerIdleCallback Register an idle handler callback.
registerRecurringTimer registers a timer that will repeatedly trigger at set intervals.
registerTimer Registers a timer task.
registerTimer Register a timer callback
requestGCCollection Request that a GC collection take place ASAP
resumeFiber Resume a suspended fiber
setFiberName Set a fiber name
setup Set the reactor up for doing work.
shouldYield Returns whether the fiber is already running for a long time.
sleep Suspend the current fiber for a specified amount of time
spawnFiber Spawn a new fiber for execution.
spawnFiber Spawn a new fiber for execution.
start Starts up the reactor.
stop Stop the reactor, killing all fibers.
suspendCurrentFiber Suspend the current fiber
teardown Shut the reactor down.
throwInFiber forward an exception to another fiber
yield Temporarily surrender the CPU for other fibers to run.

Inner structs

NameDescription
OpenOptions The options control aspects of the reactor's operation
Stats Used by reportStats to report statistics about the reactor
TimerHandle Handle used to manage registered timers

Aliases

NameDescription
IdleCallbackDlg Delegates passed to registerIdleCallback must be of this signature