Skip to content

Allow Async\Semaphore to wait for different types #166

Description

@Atry

I use Async\Semaphore to limit the concurrency in hhvm/hhast#399, which works good. But the current design of Async\Semaphore does not support the use cases where the waitForAsync callers expect different types. I wonder if we could support the following type signature, so that we can use the same Semaphore limit the concurrency of heterogeneous job types.

final class Semaphore {
  public function __construct(
    private int $concurrentLimit,
  );

  public async function waitForAsync<T>((function():Awaitable<T>) $value): Awaitable<T>;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions