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

Release lock automatically when callback returns? #3

Open
eight04 opened this issue Jan 25, 2023 · 0 comments
Open

Release lock automatically when callback returns? #3

eight04 opened this issue Jan 25, 2023 · 0 comments

Comments

@eight04
Copy link
Owner

eight04 commented Jan 25, 2023

Currently, if the callback use the release function, the lock is only released when release is called.

await lock.read(async () => {
  // do something
  return; // this lock will be released
})

await lock.read(async (release) => {
  // do something 
  if (foo) {
    // do something
    release();
  }
  // do something
  return; // this lock will NOT be released when foo === false
})

Should we always release the lock when callback returns/throw? but then we can't keep the lock after the function returns.

Or, we always release the lock when the callback is async?

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

No branches or pull requests

1 participant