Package org.apache.ignite.internal.util
Class GridBusyLock
- java.lang.Object
-
- org.apache.ignite.internal.util.GridBusyLock
-
@GridToStringExclude public class GridBusyLock extends Object
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 methodleaveBusy(). The manager itself, when stopping, should call methodblock()that blocks till all activities leave "busy" state.
-
-
Constructor Summary
Constructors Constructor Description GridBusyLock()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidblock()Blocks current thread till all activities left "busy" state and prevents them from further entering to "busy" state.booleanblockedByCurrentThread()Checks if busy lock was blocked by current thread.booleanenterBusy()Enters "busy" state.voidleaveBusy()Leaves "busy" state.voidunblock()Makes possible for activities entering busy state again.
-
-
-
Method Detail
-
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.
-
-