Visitar URL original
Support semaphores? · Issue #12 · w3c/web-locks · GitHub
Skip to content

Support semaphores? #12

Open
Open

Description

@inexorabletash

As sketched, the API would allow implementing mutexes and reader/writer locks..

It doesn't support semaphores, where a fixed number of holders can exist simultaneously. (use case: spawning up to N tasks of a given type; further requests must wait until a previous one completes)

We still want to avoid having a separate "register" step prior to the request. We could bolt this on by having a resource become a tuple (name, maxcount), or opening up the mode to be "shared"/"exclusive"/max count. That's still a bit odd since all the cooperators need to agree on what the count is (i.e. each tasks needs to know the global limit, not just some central coordinator)

I think we'd need to work through some examples here, but it at least seems plausible to add on.

Activity

  1. inexorabletash commented on Sep 22, 2017

    @inexorabletash
    MemberAuthor

    A few plausible APIs:

    const flag = await requestFlag({name:"my_resource", count: 12}, "exclusive")
    const flag = await requestFlag("my_resource", 12)

    The first makes sense to me, even if it reads a bit odd. I don't know how the second composes with multiple resource requests.

  2. added this to the v.Next milestone on Feb 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions