Closed
Conversation
# Conflicts: # classes/mutex/SpinlockMutex.php
50b6d7f to
81e0882
Compare
TheLevti
reviewed
Jul 28, 2020
Contributor
|
Thanks. So you want to have a different timeout for acquiring the lock and the maximum lock execution, correct? I think we should name the two locks then |
Contributor
|
Could you update all the files to change the naming, I'll have a better look in the coming days. |
|
this PR seems pretty interesting, is it still alive? Long time without any update on it... |
TheLevti
reviewed
Mar 6, 2021
Member
|
Thanks to #72 two timeouts are newly supported - aquire timeout ("locked timeout" terminology used here) and expire timeout. The advantage of the new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Spinlock with a twist (pun intended 😉)
Problem:
I needed to throw an exception if the lock is already taken, but only after a given timeout.
Proposed solution
The spinlock already has its own timeout (eg: 5 seconds). With this new option:
lockedTimeoutyou can now specify a timeout while lock is already taken. (eg: 3 seconds).The process will try to acquire the lock for 3 seconds then throw an exception if it doesn't succeed.
If we specify a
lockedTimeoutof 0, the exception will be thrown immediately after the first lock acquire attempt.This (with a
lockedTimeoutof zero) also addresses:#21 (comment)