FiberSchedulerInterface
The runtime that may suspend a request handler's fiber besides the server: an event loop.
The server runs every request handler in a fiber, so that the handler can wait on the client (ClientGateway). Under an event loop — Revolt (AMPHP), ReactPHP's async, any fiber scheduler — the handler's own I/O suspends that same fiber, for the loop: the server must not resume it then, the loop will. The server hands control to the scheduler instead, until the handler suspends for the server again or returns.
Without a scheduler, a handler fiber suspended by anything but the server fails the request.
Table of Contents
Methods
- wait() : void
- Lets the runtime run until $settlement settles, then returns.
Methods
wait()
Lets the runtime run until $settlement settles, then returns.
public
wait(FiberSettlement $settlement) : void
Called on the fiber — or {main} — that drives the handler, never while $settlement is already
settled. It settles from inside the handler fiber, right before that fiber suspends or returns, so
the callback given to FiberSettlement::then() must wake the driving fiber on a later turn of
the loop, never inline. Revolt's Suspension::resume() does; with ReactPHP, wrap it in
Loop::futureTick(). Returning while the handler fiber still runs fails the request.
Parameters
- $settlement : FiberSettlement