Class Locking

java.lang.Object
org.basex.core.locks.Locking

public final class Locking extends Object
Read and write locks on arbitrary strings. A maximum of StaticOptions.PARALLEL concurrent locking jobs is allowed. (Non-)fair locking can be adjusted via the StaticOptions.FAIRLOCK option. This class prevents locking deadlocks by sorting all strings. Locks can only be released by the same thread which acquired it. Locking methods are not synchronized to each other. The user must make sure not to call them in parallel by the same thread (it is fine to call arbitrary locking methods by different threads at the same time).
Author:
BaseX Team 2005-21, BSD License, Jens Erat
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Special lock identifier for backup commands.
    static final String
    Prefix for query locks.
    static final String
    Special lock identifier for collection available via current context; will be substituted.
    static final String
    Special lock identifier for database opened in current context; will be substituted.
    static final String
    Prefix for internal special locks.
    static final String
    Special lock identifier for repository commands.
    static final String
    Special lock identifier for user commands.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    acquire(Job job, Context ctx)
    Acquires locks for the specified job.
    static String[]
    queryLocks(byte[] string)
    Returns query lock keys.
    void
    Removes locks for the specified job, all in reverse order.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Locking

      public Locking(StaticOptions soptions)
      Constructor.
      Parameters:
      soptions - static options
  • Method Details

    • acquire

      public void acquire(Job job, Context ctx)
      Acquires locks for the specified job.
      Parameters:
      job - job to be queued
      ctx - database context of client
    • release

      public void release()
      Removes locks for the specified job, all in reverse order.
    • queryLocks

      public static String[] queryLocks(byte[] string)
      Returns query lock keys.
      Parameters:
      string - string with lock keys
      Returns:
      locks
    • toString

      public String toString()
      Overrides:
      toString in class Object