Interface HeldLocks.Revocable

Enclosing class:
HeldLocks

public static interface HeldLocks.Revocable
A lock whose release may happen where nothing reports it, so its hold is re-confirmed against the lock itself whenever this thread's set is read.

A compare-and-swap spinlock is the case (#558). The agent sees the swap that takes it, but a release can go through a call it does not substitute - an updateAndGet, an Unsafe store, code it does not weave - and a lock that outlives its release makes every later access on this thread look guarded, which hides a real race. Asking the flag whether this thread still holds it turns an invisible release into an observed one the next time the set matters. An entry whose stillHeld() answers false, or throws, leaves the set.

Since:
1.12.1
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns whether the calling thread still holds this lock.
  • Method Details

    • stillHeld

      boolean stillHeld()
      Returns whether the calling thread still holds this lock.

      Called on the holding thread, on the hot path of every access recorded while the lock is in the set, so it must be allocation-free and must not call back into this class.

      Returns:
      whether the calling thread still holds this lock