Enum Class LockMode

java.lang.Object
java.lang.Enum<LockMode>
org.cojen.tupl.LockMode
All Implemented Interfaces:
Serializable, Comparable<LockMode>, Constable

public enum LockMode extends Enum<LockMode>
Various lock modes for use within transactions. Except for UNSAFE, all modes follow the same policy when modifying entries. They all differ with respect to entries which are being read.

When an entry is modified, an exclusive lock is acquired, which is typically held until the end of the transaction. When transaction scopes are committed, all held locks transfer to the parent scope. Uncommitted scopes release all of their acquired locks.

Modes ordered from strongest to weakest:

See Also:
  • Enum Constant Details

    • UPGRADABLE_READ

      public static final LockMode UPGRADABLE_READ
      Lock mode which acquires upgradable locks when reading entries and retains them to the end of the transaction or scope. If an entry guarded by an upgradable lock is modified, the lock is first upgraded to be exclusive.
    • REPEATABLE_READ

      public static final LockMode REPEATABLE_READ
      Lock mode which acquires shared locks when reading entries and retains them to the end of the transaction or scope. Attempting to modify entries guarded by a shared lock is illegal. Consider using UPGRADABLE_READ instead.
      See Also:
    • READ_COMMITTED

      public static final LockMode READ_COMMITTED
      Lock mode which acquires shared locks when reading entries and releases them as soon as possible.
    • READ_UNCOMMITTED

      public static final LockMode READ_UNCOMMITTED
      Lock mode which never acquires locks when reading entries. Modifications made by concurrent transactions are visible for reading, but they might get rolled back.
    • UNSAFE

      public static final LockMode UNSAFE
      Lock mode which never acquires locks. This mode bypasses all transactional safety, permitting modifications even when locked by other transactions. These modifications are immediately committed, and so rollback is not possible.
  • Method Details

    • values

      public static LockMode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static LockMode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isRepeatable

      public boolean isRepeatable()
      Returns true if acquired locks are retained for the duration of the transaction. Applicable to UPGRADABLE_READ and REPEATABLE_READ.