Method
phasync::raiseFlag
Wakes every coroutine waiting for $signal in phasync::awaitFlag, and returns how many it woke.
Description#
public static phasync::raiseFlag(
object $signal
): intA flag is any object: the one the waiters and the raiser share is the signal. Raising a flag nobody waits for does nothing, and is not remembered. This and awaitFlag() are what the other waits of phasync are built on.
Parameters#
- $signal object
Return values#
The number of coroutines woken int
Examples#
phasync::run(function () {
$ready = new stdClass();
phasync::go(function () use ($ready) {
phasync::awaitFlag($ready);
echo "ready\n";
});
echo phasync::raiseFlag($ready), " woken\n"; // 1 woken
});See also#
phasync::awaitFlagSuspends the current coroutine until$signalis raised withphasync::raiseFlag.