Skip to content
  • Michael Hanselmann's avatar
    locking: Implement opportunistic locking in LockSet · a95c53ea
    Michael Hanselmann authored
    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: default avatarMichael Hanselmann <hansmi@google.com>
    Reviewed-by: default avatarIustin Pop <iustin@google.com>
    a95c53ea