Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support semaphores? #12

Open
inexorabletash opened this issue Sep 22, 2017 · 1 comment
Open

Support semaphores? #12

inexorabletash opened this issue Sep 22, 2017 · 1 comment
Milestone

Comments

@inexorabletash
Copy link
Member

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.

@inexorabletash
Copy link
Member Author

inexorabletash commented Sep 22, 2017

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.

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

No branches or pull requests

1 participant