Package com.tangosol.util
Class WrapperReentrantGate
java.lang.Object
com.tangosol.util.WrapperReentrantGate
A Gate implementation that allows for 2^31 reentrant enter calls by a single
 thread.
- Since:
 - Coherence 3.7
 - Author:
 - coh 2010.10.14
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.oracle.coherence.common.util.SentrySentry to return fromenter(long)that willexit()when the sentry is closed. - 
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.WrapperReentrantGate(Gate<Void> gate) Construct a WrapperReentrantGate around the specified underlying gate. - 
Method Summary
Modifier and TypeMethodDescriptionbooleanbarEntry(long cMillis) Bar entry to the thread gate by other threads, but do not wait for the gate to close.com.oracle.coherence.common.util.Sentryclose()Wait to close the gate.booleanclose(long cMillis) Close the gate.com.oracle.coherence.common.util.Sentryenter()Wait to enter the gate.booleanenter(long cMillis) Enter the gate.voidexit()Exit the gate.booleanisClosed()Determine if any thread has closed the gate and continues to hold exclusive access.booleanDetermine if the calling thread has closed the gate and continues to hold exclusive access.booleanDetermines if the current thread has entered the gate and not yet exited.voidopen()Re-open the closed gate. 
- 
Field Details
- 
f_exitSentry
protected final com.oracle.coherence.common.util.Sentry f_exitSentrySentry to return fromenter(long)that willexit()when the sentry is closed. 
 - 
 - 
Constructor Details
- 
WrapperReentrantGate
public WrapperReentrantGate()Default constructor. - 
WrapperReentrantGate
Construct a WrapperReentrantGate around the specified underlying gate.- Parameters:
 gate- aGateto be wrapped
 
 - 
 - 
Method Details
- 
close
public boolean close(long cMillis) Close the gate. A thread uses this method to obtain exclusive access to the resource represented by the gate. Each invocation of this method must ultimately have a corresponding invocation of theGate.open()method.- Specified by:
 closein interfacecom.oracle.coherence.common.util.Gate<Void>- Parameters:
 cMillis- maximum number of milliseconds to wait; pass -1 to wait indefinitely or 0 to return immediately- Returns:
 - true iff entry into the gate was successfully closed by the calling thread and no other threads remain in the gate
 
 - 
open
public void open()Re-open the closed gate. This method can be called only if the calling thread successfully closed the gate.- Specified by:
 openin interfacecom.oracle.coherence.common.util.Gate<Void>
 - 
enter
public boolean enter(long cMillis) Enter the gate. A thread uses this method to obtain non-exclusive access to the resource represented by the gate. Each invocation of this method must ultimately have a corresponding invocation of theGate.exit()method.- Specified by:
 enterin interfacecom.oracle.coherence.common.util.Gate<Void>- Parameters:
 cMillis- maximum number of milliseconds to wait; pass -1 to wait indefinitely or 0 to return immediately- Returns:
 - true iff the calling thread successfully entered the gate
 
 - 
close
public com.oracle.coherence.common.util.Sentry close()Description copied from interface:com.oracle.coherence.common.util.GateWait to close the gate.- Specified by:
 closein interfacecom.oracle.coherence.common.util.Gate<Void>- Returns:
 - an AutoCloseable which can be used with a try-with-resource block to perform the corresponding 
Gate.open(). 
 - 
enter
public com.oracle.coherence.common.util.Sentry enter()Description copied from interface:com.oracle.coherence.common.util.GateWait to enter the gate.- Specified by:
 enterin interfacecom.oracle.coherence.common.util.Gate<Void>- Returns:
 - an AutoCloseable which can be used with a try-with-resource block to perform the corresponding 
Gate.exit(). 
 - 
exit
public void exit()Exit the gate. A thread must invoke this method corresponding to each invocation of theGate.enter()method.- Specified by:
 exitin interfacecom.oracle.coherence.common.util.Gate<Void>
 - 
barEntry
public boolean barEntry(long cMillis) Bar entry to the thread gate by other threads, but do not wait for the gate to close. When all other threads have exited, the status of the thread gate will be closeable by the thread which barred entry. Threads that have already entered the gate at the time of this method call should be allowed to succeed in additional #enter calls.Each successful invocation of this method must ultimately have a corresponding invocation of the open method (assuming the thread gate is not destroyed) even if the calling thread does not subsequently close the gate.
gate.barEntry(-1); try { // processing that does not require the gate to be closed // ... } finally { gate.close(-1); try { // processing that does require the gate to be closed // ... } finally { gate.open(); // matches gate.close() } gate.open(); // matches gate.barEntry() }- Specified by:
 barEntryin interfacecom.oracle.coherence.common.util.Gate<Void>- Parameters:
 cMillis- maximum number of milliseconds to wait; pass -1 for forever or 0 for no wait- Returns:
 - true iff entry into the thread gate was successfully barred by the calling thread
 
 - 
isClosedByCurrentThread
public boolean isClosedByCurrentThread()Determine if the calling thread has closed the gate and continues to hold exclusive access.- Specified by:
 isClosedByCurrentThreadin interfacecom.oracle.coherence.common.util.Gate<Void>- Returns:
 - true iff the calling thread holds exclusive access to the gate
 
 - 
isEnteredByCurrentThread
public boolean isEnteredByCurrentThread()Determines if the current thread has entered the gate and not yet exited.- Specified by:
 isEnteredByCurrentThreadin interfacecom.oracle.coherence.common.util.Gate<Void>- Returns:
 - true if the current thread has entered the gate
 
 - 
isClosed
public boolean isClosed()Determine if any thread has closed the gate and continues to hold exclusive access.- Specified by:
 isClosedin interfacecom.oracle.coherence.common.util.Gate<Void>- Returns:
 - true iff there is a thread that holds exclusive access to the gate
 
 
 -