|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ILockable
Interface describing a resource that can be locked by a task.
| Method Summary | |
|---|---|
void |
addLockListener(ILockListener listener)
Add a listener to be notified of locking state changes of the resource. |
LockPriority |
getLockPriority()
Provides the priority of the task holding the lock. |
boolean |
isLocked()
Checks whether the resource is locked by any task. |
void |
lock()
Obtains the exclusive lock on this resource. |
boolean |
ownsLock()
Checks whether the calling task (thread group) holds this lock. |
void |
removeLockListener(ILockListener listener)
Removes a previously registered locking state listener. |
void |
unlock()
Releases the lock if the calling task (thread group) owns it. |
| Method Detail |
|---|
void lock()
throws LockException,
InterruptedException
Locking task is identified by its thread group. Once locked, no other task can obtain the lock. A task with
higher priority can force the lock by calling #forceLock().
This function call blocks until the lock is successful or timeout expires.
Keep in mind to release the lock with unlock() once the lock is not needed anymore.
LockTimeoutException - if the locking attempt timed out.
ResourceAlreadyLockedException - if the resource is already locked by another task.
LockException - if locking failed for some reason.
InterruptedException - if the thread was interrupted while waiting for the lock.void unlock()
Only the task (thread group) that holds the lock can unlock the resource.
Unlocking might not be completed yet on method return, but any following lock() or #forceLock()
on this resource will wait for the unlock to complete.
boolean isLocked()
If it is of interest if the resource is locked by the calling task, please use the ownsLock().
true if resource is locked; otherwise false.boolean ownsLock()
true if calling task (thread group) holds this lock; otherwise false.LockPriority getLockPriority()
void addLockListener(ILockListener listener)
listener - The listener to call.void removeLockListener(ILockListener listener)
listener - The listener to remove.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||