Skip to content

[Proposal] Add a CountDownLatch implementation #371

Open
@navaronbracke

Description

@navaronbracke

I recently stumbled upon a use case where I could use a count down latch implementation.

However, I didn't find any such implementation in package:async.
I propose we add one here.

In terms of API surface, all it needs to do in my opinion is the following:

  • keep track of a "count" as a internal counter and as an internal stream of said counter
  • provide a method to increment / decrement the latch
  • provide a Future<void> wait() method, which is essentially an await firstWhere((count) => count == 0);
  • provide a void reset(); which just resets the latch

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions