Requires the Hack Standard Library to be installed.
Facebook Engineer?

This function is available as Async\Semaphore() in Facebook's www repository.

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 funtion 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