org.exist.storage.lock
Interface Lock

All Known Implementing Classes:
MultiReadReentrantLock, ReentrantReadWriteLock

public interface Lock


Field Summary
static int NO_LOCK
           
static int READ_LOCK
           
static int WRITE_LOCK
           
 
Method Summary
 boolean acquire()
          Acquire a lock for read.
 boolean acquire(int mode)
          Acquire a lock for read or write.
 boolean attempt(int mode)
          Attempt to acquire a lock for read or write.
 String getId()
           
 LockInfo getLockInfo()
          Create a LockInfo entry for the given lock.
 boolean hasLock()
          Check if the lock is currently locked by someone.
 boolean hasLock(Thread owner)
          Check if the specified thread holds either a write or a read lock on the resource.
 boolean isLockedForRead(Thread owner)
          Check if the specified thread does currently hold a read lock.
 boolean isLockedForWrite()
          Returns true if there are active or pending write locks.
 void release(int mode)
          Release a lock of the specified type.
 void release(int mode, int count)
           
 void wakeUp()
          Wake up waiting threads and recompute dependencies.
 

Field Detail

READ_LOCK

static final int READ_LOCK
See Also:
Constant Field Values

WRITE_LOCK

static final int WRITE_LOCK
See Also:
Constant Field Values

NO_LOCK

static final int NO_LOCK
See Also:
Constant Field Values
Method Detail

acquire

boolean acquire()
                throws LockException
Acquire a lock for read.

Throws:
LockException

acquire

boolean acquire(int mode)
                throws LockException
Acquire a lock for read or write. mode is one of READ_LOCK or WRITE_LOCK.

Parameters:
mode -
Throws:
LockException

attempt

boolean attempt(int mode)
Attempt to acquire a lock for read or write. This method will fail immediately if the lock cannot be acquired.

Parameters:
mode -

release

void release(int mode)
Release a lock of the specified type.

Parameters:
mode -

release

void release(int mode,
             int count)

isLockedForWrite

boolean isLockedForWrite()
Returns true if there are active or pending write locks.


isLockedForRead

boolean isLockedForRead(Thread owner)
Check if the specified thread does currently hold a read lock.

Parameters:
owner - the thread to search for
Returns:
true if the thread holds a read lock

hasLock

boolean hasLock()
Check if the lock is currently locked by someone.

Returns:
true if there's an active read or write lock

hasLock

boolean hasLock(Thread owner)
Check if the specified thread holds either a write or a read lock on the resource.

Parameters:
owner - the thread
Returns:
true if owner has a lock

wakeUp

void wakeUp()
Wake up waiting threads and recompute dependencies. Currently used to rerun deadlock detection.


getId

String getId()

getLockInfo

LockInfo getLockInfo()
Create a LockInfo entry for the given lock.

Returns:
the lock info


Copyright (C) Wolfgang Meier. All rights reserved.