Package org.apache.ignite.internal.util
Class GridBusyLock
java.lang.Object
org.apache.ignite.internal.util.GridBusyLock
Synchronization aid to track "busy" state of a subsystem that owns it.
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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidblock()Blocks current thread till all activities left "busy" state and prevents them from further entering to "busy" state.booleanChecks if busy lock was blocked by current thread.booleanEnters "busy" state.voidLeaves "busy" state.voidunblock()Makes possible for activities entering busy state again.
-
Constructor Details
-
GridBusyLock
public GridBusyLock()
-
-
Method Details
-
enterBusy
public boolean enterBusy()Enters "busy" state.- Returns:
trueif entered to busy state.
-
blockedByCurrentThread
public boolean blockedByCurrentThread()Checks if busy lock was blocked by current thread.- Returns:
Trueif busy lock was blocked by current thread.
-
leaveBusy
public void leaveBusy()Leaves "busy" state. -
block
public void block()Blocks current thread till all activities left "busy" state and prevents them from further entering to "busy" state. -
unblock
public void unblock()Makes possible for activities entering busy state again.
-