phasync
phasync / frame

Method

phasync::frame

Returns the frame of the running coroutine: that of the innermost run() it is in.

Description#

public static phasync::frame(): Frame

A coroutine belongs to the frame of the run() that started it, and a nested run() gives the coroutine that calls it a new frame until it returns.

Return values#

Frame

Errors / Exceptions#

ExceptionWhen
LogicExceptionOutside a coroutine, and in a service, which has no frame

Examples#

Example 1
phasync::run(function () {
    phasync::frame()->setTimeout(1.0);   // this run(), and every coroutine started inside it
});

See also#

  • FrameThe lifetime of a phasync::run() call: the coroutines started inside it, which it waits for, cancels and rethrows.
  • phasync::runRuns $fn and returns its result once it and every coroutine started inside it have ended.