Package org.basex.core.locks
Class Locking
java.lang.Object
org.basex.core.locks.Locking
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
FieldsModifier and TypeFieldDescriptionstatic final StringSpecial lock identifier for backup commands.static final StringPrefix for query locks.static final StringSpecial lock identifier for collection available via current context; will be substituted.static final StringSpecial lock identifier for database opened in current context; will be substituted.static final StringPrefix for internal special locks.static final StringSpecial lock identifier for repository commands.static final StringSpecial lock identifier for user commands. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
INTERNAL_PREFIX
Prefix for internal special locks.- See Also:
-
BASEX_PREFIX
Prefix for query locks.- See Also:
-
CONTEXT
Special lock identifier for database opened in current context; will be substituted.- See Also:
-
COLLECTION
Special lock identifier for collection available via current context; will be substituted.- See Also:
-
USER
Special lock identifier for user commands.- See Also:
-
BACKUP
Special lock identifier for backup commands.- See Also:
-
REPO
Special lock identifier for repository commands.- See Also:
-
-
Constructor Details
-
Locking
Constructor.- Parameters:
soptions- static options
-
-
Method Details
-
acquire
Acquires locks for the specified job.- Parameters:
job- job to be queuedctx- database context of client
-
release
public void release()Removes locks for the specified job, all in reverse order. -
queryLocks
Returns query lock keys.- Parameters:
string- string with lock keys- Returns:
- locks
-
toString
-