locking: Implement opportunistic locking in LockSet
This patch adds a new parameter to “LockSet.acquire” named “opportunistic”. When enabled the lockset will try to acquire as many locks as possible, but it won't wait for them (with the exception of the lockset-internal lock in case the whole set is acquired). This is implemented by using a timeout of 0 seconds when acquiring individual locks. Commit 03c5291c made such acquisitions significantly cheaper. The most complicated code included in this patch is probably the helper function used to determine which mode to use and which timeout functions are needed. Full unit tests are included for the new and changed code (“locking.py”'s overall coverage is at 97%). Signed-off-by:Michael Hanselmann <hansmi@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
Loading
Please register or sign in to comment