FiberRuntime
in package
implements
Runtime
Tags
Table of Contents
Interfaces
- Runtime
- Abstraction over the concurrency backend that powers the actor system.
Methods
- __construct() : mixed
- createFutureSlot() : FutureSlot
- Create a lightweight value slot for the ask pattern.
- createMailbox() : Mailbox<string|int, TM>
- Create a new mailbox governed by `$config`.
- isRunning() : bool
- Return `true` if the runtime event loop is currently active.
- name() : string
- Return the human-readable name that identifies this runtime implementation.
- run() : void
- Start the runtime event loop and block until all actors have shut down.
- scheduleOnce() : Cancellable
- Schedule `$callback` to run once after `$delay` has elapsed.
- scheduleRepeatedly() : Cancellable
- Schedule `$callback` to run repeatedly, starting after `$initialDelay`.
- shutdown() : void
- Initiate a graceful shutdown and wait up to `$timeout` for completion.
- sleep() : void
- Suspend the current fiber or coroutine for `$duration`.
- spawn() : string
- Spawn a new fiber or coroutine to run `$actorLoop`.
- yield() : void
- Cooperatively yield execution to allow other fibers or coroutines to run.
Methods
__construct()
public
__construct() : mixed
createFutureSlot()
Create a lightweight value slot for the ask pattern.
public
createFutureSlot() : FutureSlot
The caller is responsible for scheduling timeout failures.
Return values
FutureSlotcreateMailbox()
Create a new mailbox governed by `$config`.
public
createMailbox(MailboxConfig $config) : Mailbox<string|int, TM>
Parameters
- $config : MailboxConfig
Tags
Return values
Mailbox<string|int, TM>isRunning()
Return `true` if the runtime event loop is currently active.
public
isRunning() : bool
Return values
boolname()
Return the human-readable name that identifies this runtime implementation.
public
name() : string
Return values
stringrun()
Start the runtime event loop and block until all actors have shut down.
public
run() : void
For FiberRuntime this drives the fiber scheduler. For SwooleRuntime this
enters the Swoole event loop. Returns only after shutdown() completes.
scheduleOnce()
Schedule `$callback` to run once after `$delay` has elapsed.
public
scheduleOnce(Duration $delay, callable $callback) : Cancellable
Returns a Cancellable that can be used to abort the pending callback before
it fires. The callback is invoked in the runtime's execution context.
Parameters
- $delay : Duration
- $callback : callable
Return values
CancellablescheduleRepeatedly()
Schedule `$callback` to run repeatedly, starting after `$initialDelay`.
public
scheduleRepeatedly(Duration $initialDelay, Duration $interval, callable $callback) : Cancellable
Subsequent invocations are spaced $interval apart. Returns a Cancellable
to stop future invocations.
Parameters
Return values
Cancellableshutdown()
Initiate a graceful shutdown and wait up to `$timeout` for completion.
public
shutdown(Duration $timeout) : void
Signals all actors to stop, drains pending messages, and exits the event loop.
Parameters
- $timeout : Duration
sleep()
Suspend the current fiber or coroutine for `$duration`.
public
sleep(Duration $duration) : void
Unlike usleep(), this does not block the OS thread — other actors continue
to process messages while this one sleeps.
Parameters
- $duration : Duration
spawn()
Spawn a new fiber or coroutine to run `$actorLoop`.
public
spawn(callable $actorLoop) : string
The runtime starts the loop immediately (or schedules it for the next tick) and returns an opaque identifier string for observability.
Parameters
- $actorLoop : callable
Return values
stringyield()
Cooperatively yield execution to allow other fibers or coroutines to run.
public
yield() : void
Called inside actor message loops to prevent one busy actor from starving others.