Class LockingGate
- java.lang.Object
-
- com.hybris.cockpitng.testing.util.LockingGate
-
public class LockingGate extends java.lang.ObjectA gate that allow easy awaiting and locking in multithread tests.
-
-
Constructor Summary
Constructors Constructor Description LockingGate()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassureInLockingThread()protected voidassureInUnlockingThread()voidassureLocked()Awaits until gate is locked - some thread callslock()method.protected java.lang.ThreadassureLockingThreadRegistered()protected java.lang.ThreadassureUnlockingThreadRegistered()java.lang.ThreadgetLockingThread()Gets a thread that is expected to calllock()methodjava.lang.ThreadgetUnlockingThread()Gets a thread that is expected to callunlock()methodvoidlock()Locks this gate.voidregisterLockingThread()Marks current thread as the one to calllock()methodvoidregisterUnlockingThread()Marks current thread as the one to callunlock()methodvoidunlock()Unlocks this gate.
-
-
-
Method Detail
-
getUnlockingThread
public java.lang.Thread getUnlockingThread()
Gets a thread that is expected to callunlock()method- Returns:
- thread to unlock gate
-
getLockingThread
public java.lang.Thread getLockingThread()
Gets a thread that is expected to calllock()method- Returns:
- thread to lock gate
-
registerLockingThread
public void registerLockingThread()
Marks current thread as the one to calllock()method
-
registerUnlockingThread
public void registerUnlockingThread()
Marks current thread as the one to callunlock()method
-
assureLocked
public void assureLocked()
Awaits until gate is locked - some thread callslock()method. Method returns immediately, if gate is already locked. Current thread is considered as the one to callunlock()method.- See Also:
registerUnlockingThread()
-
lock
public void lock()
Locks this gate. If unlocker is already waiting for gate to be locked (seeassureLocked()), it is released. Method return immediately, if gate was already unlocked (seeunlock()) by other thread - otherwise current thread awaits until gate gets unlocked.- See Also:
registerLockingThread()
-
assureInLockingThread
protected void assureInLockingThread()
-
assureUnlockingThreadRegistered
protected java.lang.Thread assureUnlockingThreadRegistered()
-
unlock
public void unlock()
Unlocks this gate. If a locking thread is already waiting for gate to be unlocked (seelock()), it is released.
-
assureInUnlockingThread
protected void assureInUnlockingThread()
-
assureLockingThreadRegistered
protected java.lang.Thread assureLockingThreadRegistered()
-
-