|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Synchronization object for setting exlusive and shared locks.
Locks are not nested - if session sets the same lock several time,
all lock requests are succeed but single unlock request will
unlock the object. It is possible to upgrade the lock:
if session first lock object in shared mode and then in exclusive
mode, lock will be upgraded to exclusive (Attention! upgrading
locks can easily cause a deadlock if several session will try to upgrade
their shared locks simultaneously).
It is not possible to downgrade the lock - locking of object in shared
mode after granted exlusive lock has no effect.
Locks are granted in FIFO order - it means that if object is locked
shared mode, then request for exclusive lock comes and is blocked and
then if yet another request for shared lock is received, it will
be also blocked and placed inqueue after excusive lock request.
Server is able to detect deadlock for this primitive.
Semantic of methods inherited from JIPCPrimitive
:
waitFor
reset
reset
method be owner of this lock
Field Summary |
Fields inherited from interface org.garret.jipc.JIPCPrimitive |
DEFAULT_RANK |
Method Summary | |
void |
exclusiveLock()
Set exlusive lock. |
boolean |
exclusiveLock(long timeout)
Set exclusive lock with timeout. |
void |
priorityExclusiveLock(int rank)
Set exlusive lock. |
boolean |
priorityExclusiveLock(int rank,
long timeout)
Set exclusive lock with timeout. |
void |
prioritySharedLock(int rank)
Set shared lock. |
boolean |
prioritySharedLock(int rank,
long timeout)
Set shared lock with timeout. |
void |
sharedLock()
Set shared lock. |
boolean |
sharedLock(long timeout)
Set shared lock with timeout. |
void |
unlock()
Remove lock from the object |
Methods inherited from interface org.garret.jipc.JIPCPrimitive |
alreadyExists, close, getName, priorityWait, priorityWait, reset, waitFor, waitFor |
Method Detail |
public void exclusiveLock() throws JIPCException, java.io.IOException
JIPCException
java.io.IOException
public boolean exclusiveLock(long timeout) throws JIPCException, java.io.IOException
timeout
- time in milliseconds
true
if lock is granted, false
of timeout
is expired
JIPCException
java.io.IOException
public void priorityExclusiveLock(int rank) throws JIPCException, java.io.IOException
rank
- processes will be placed in wait queue in the order of increasing
rank value and in the same order will be taken from the queue.
JIPCException
java.io.IOException
public boolean priorityExclusiveLock(int rank, long timeout) throws JIPCException, java.io.IOException
rank
- processes will be placed in wait queue in the order of increasing
rank value and in the same order will be taken from the queue.timeout
- time in milliseconds
true
if lock is granted, false
of timeout
is expired
JIPCException
java.io.IOException
public void prioritySharedLock(int rank) throws JIPCException, java.io.IOException
rank
- processes will be placed in wait queue in the order of increasing
rank value and in the same order will be taken from the queue.
JIPCException
java.io.IOException
public boolean prioritySharedLock(int rank, long timeout) throws JIPCException, java.io.IOException
rank
- processes will be placed in wait queue in the order of increasing
rank value and in the same order will be taken from the queue.timeout
- time in milliseconds
true
if lock is granted, false
of timeout
is expired
JIPCException
java.io.IOException
public void sharedLock() throws JIPCException, java.io.IOException
JIPCException
java.io.IOException
public boolean sharedLock(long timeout) throws JIPCException, java.io.IOException
timeout
- time in milliseconds
true
if lock is granted, false
of timeout
is expired
JIPCException
java.io.IOException
public void unlock() throws JIPCException, java.io.IOException
JIPCException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |