Package org.jgroups.protocols
Class Locking.ClientLock
- java.lang.Object
-
- org.jgroups.protocols.Locking.ClientLock
-
- All Implemented Interfaces:
java.lang.Comparable<Locking.ClientLock>
,java.util.concurrent.locks.Lock
- Enclosing class:
- Locking
protected class Locking.ClientLock extends java.lang.Object implements java.util.concurrent.locks.Lock, java.lang.Comparable<Locking.ClientLock>
Implementation ofLock
. This is a client stub communicates with a server equivalent. The semantics are more or less those ofLock
, but may differ slightly. For details seeLockService
.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
acquired
protected Locking.ClientCondition
condition
protected boolean
denied
protected boolean
is_trylock
protected int
lock_id
protected java.lang.String
name
protected Owner
owner
protected long
timeout
-
Constructor Summary
Constructors Constructor Description ClientLock(java.lang.String name)
ClientLock(java.lang.String name, Owner owner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_unlock(boolean force)
protected void
_unlockOK()
protected void
acquire(boolean throwInterrupt)
protected boolean
acquireTryLock(long timeout, boolean use_timeout)
int
compareTo(Locking.ClientLock o)
boolean
equals(java.lang.Object obj)
protected void
handleLockGrantedResponse(int lock_id)
protected void
handleLockReleasedResponse(int lock_id)
boolean
isHeld()
void
lock()
protected void
lockDenied(int lock_id)
protected void
lockGranted(int lock_id)
void
lockInterruptibly()
java.util.concurrent.locks.Condition
newCondition()
java.lang.String
toString()
boolean
tryLock()
boolean
tryLock(long time, java.util.concurrent.TimeUnit unit)
void
unlock()
-
-
-
Field Detail
-
name
protected final java.lang.String name
-
owner
protected Owner owner
-
acquired
protected volatile boolean acquired
-
denied
protected volatile boolean denied
-
is_trylock
protected volatile boolean is_trylock
-
timeout
protected long timeout
-
condition
protected final Locking.ClientCondition condition
-
lock_id
protected final int lock_id
-
-
Constructor Detail
-
ClientLock
public ClientLock(java.lang.String name)
-
ClientLock
public ClientLock(java.lang.String name, Owner owner)
-
-
Method Detail
-
isHeld
public boolean isHeld()
-
lock
public void lock()
- Specified by:
lock
in interfacejava.util.concurrent.locks.Lock
-
lockInterruptibly
public void lockInterruptibly() throws java.lang.InterruptedException
- Specified by:
lockInterruptibly
in interfacejava.util.concurrent.locks.Lock
- Throws:
java.lang.InterruptedException
-
tryLock
public boolean tryLock()
- Specified by:
tryLock
in interfacejava.util.concurrent.locks.Lock
-
tryLock
public boolean tryLock(long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
tryLock
in interfacejava.util.concurrent.locks.Lock
- Throws:
java.lang.InterruptedException
-
unlock
public void unlock()
- Specified by:
unlock
in interfacejava.util.concurrent.locks.Lock
-
newCondition
public java.util.concurrent.locks.Condition newCondition()
- Specified by:
newCondition
in interfacejava.util.concurrent.locks.Lock
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
lockGranted
protected void lockGranted(int lock_id)
-
lockDenied
protected void lockDenied(int lock_id)
-
handleLockGrantedResponse
protected void handleLockGrantedResponse(int lock_id)
-
handleLockReleasedResponse
protected void handleLockReleasedResponse(int lock_id)
-
acquire
protected void acquire(boolean throwInterrupt) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
_unlock
protected void _unlock(boolean force)
-
_unlockOK
protected void _unlockOK()
-
acquireTryLock
protected boolean acquireTryLock(long timeout, boolean use_timeout) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
compareTo
public int compareTo(Locking.ClientLock o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Locking.ClientLock>
-
-