We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
lockWith
tryLockWith
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
Being able to wrap the lock process inside a function could be nice.
So the following code:
async function doSomething() { const mutex = new Mutex(); let data = 0; await mutex.lock(); const myValue = 123; data = myValue * 2; await mutex.unlock(); // data === 246 }
Could be rewritten as follows:
async function doSomething() { const mutex = new Mutex(); const data = await mutex.lockWith(async () => { const myValue = 123; return myValue * 2; }) // data === 246 }
The text was updated successfully, but these errors were encountered:
feat(mutex): add lockWith and tryLockWith definitions
2bc30d7
start #2
test(mutex): add test for lockWith functions
a3606c5
#2
feat(mutex): add lockWith and tryLockWith bodies
01135a6
closes #2
Merge pull request #8 from heap-code/dev/2-lock-with
1cc8e7e
`lockWith` #2
HugoMendes98
Successfully merging a pull request may close this issue.
Being able to wrap the lock process inside a function could be nice.
So the following code:
Could be rewritten as follows:
The text was updated successfully, but these errors were encountered: