HH\Lib\Async\Semaphore
Run an operation with a limit on number of ongoing asynchronous jobs
All operations must have the same input type (Tin
) and output type (Tout
),
and be processed by the same function; Tin
may be a callable invoked by the
function for maximum flexibility, however this pattern is best avoided in favor
of creating semaphores with a more narrow process.
Use genWaitFor()
to retrieve a Tout
from a Tin
.
Interface Synopsis
namespace HH\Lib\Async;
final class Semaphore {...}
Public Methods
->__construct(int $concurrentLimit, (function(Tin): Awaitable<Tout>) $f)
Create a semaphore->waitForAsync(Tin $value): Awaitable<Tout>
Produce aTout
from aTin
, respecting the concurrency limit