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

Implement multiple locks at the same time. #3

Open
martinheidegger opened this issue Feb 23, 2018 · 0 comments
Open

Implement multiple locks at the same time. #3

martinheidegger opened this issue Feb 23, 2018 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@martinheidegger
Copy link
Owner

Right now, require('flexlock/createLocker') only allows a single key to lock towards lock(key, ...) but some code requires multiple resources to work, a new API that works like lock([keyA, keyB], ...) would be good. The obvious implementation would be to just use Promise.all to await three locks, but a more-complex implementation that allows other sublocks to receive early might be not a bad idea. In an example:

  1. (A) lock(['users', 'user:11'], ...) → ... processing
  2. (B) lock(['users', 'user:12'], ...) → ... waiting for (A) to finish
  3. (C) lock('user:12') → processing
  4. (A) finished, (B) → waiting for (C) to finish
  5. (C) finished, (B) → processing
  6. (B) finished

In that example (C) can start processing without waiting for (B) to finish because it only uses part of the resources of (B). This would require a more complicated implementation though.

@martinheidegger martinheidegger added enhancement New feature or request help wanted Extra attention is needed labels Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant