@GridToStringExclude public class GridSpinBusyLock extends Object
Main difference over GridBusyLock
is that this class is implemented
over GridSpinReadWriteLock
.
For example, there may be a manager that have different threads for some
purposes and the manager must not be stopped while at least a single thread
is in "busy" state. In this situation each thread must enter to "busy"
state calling method enterBusy()
in critical pieces of code
which, i.e. use grid kernal functionality, notifying that the manager
and the whole grid kernal cannot be stopped while it's in progress. Once
the activity is done, the thread should leave "busy" state calling method
leaveBusy()
. The manager itself, when stopping, should call method
block()
that blocks till all activities leave "busy" state.
GridBusyLock
,
GridSpinReadWriteLock
Constructor and Description |
---|
GridSpinBusyLock() |
Modifier and Type | Method and Description |
---|---|
void |
block()
Blocks current thread till all activities left "busy" state
and prevents them from further entering to "busy" state.
|
boolean |
blockedByCurrentThread()
Checks if busy lock was blocked by current thread.
|
boolean |
enterBusy()
Enters "busy" state.
|
void |
leaveBusy()
Leaves "busy" state.
|
boolean |
tryBlock(long millis) |
void |
unblock()
Makes possible for activities entering busy state again.
|
public boolean enterBusy()
true
if entered to busy state.public boolean blockedByCurrentThread()
True
if busy lock was blocked by current thread.public void leaveBusy()
public void block()
public boolean tryBlock(long millis) throws InterruptedException
millis
- Timeout.True
if lock was acquired.InterruptedException
- If interrupted.public void unblock()
Follow @ApacheIgnite
Ignite Fabric : ver. 2.0.0 Release Date : April 30 2017