public final class ThreadGateLite<R> extends Object implements Gate<R>
ReentrantReadWriteLock.| Modifier and Type | Class and Description | 
|---|---|
protected static class  | 
ThreadGateLite.Bar
Bar represents the state of the  
bars placed on this gate. | 
| Modifier and Type | Field and Description | 
|---|---|
protected com.oracle.common.util.Sentry<R> | 
f_exitSentry
 | 
protected com.oracle.common.util.Sentry<R> | 
f_openSentry
 | 
| Constructor and Description | 
|---|
ThreadGateLite()
Default constructor. 
 | 
ThreadGateLite(R resource)
Construct a ThreadGateLite protected the specified resource. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
protected long | 
adjustWaitTime(long cMillis,
              long ldtStart)
Calculate the time remaining from the total time allotted for an operation. 
 | 
boolean | 
barEntry(long cMillis)
Bar entry to the thread gate by other threads, but do not wait for the
 gate to close. 
 | 
com.oracle.common.util.Sentry<R> | 
close()
Wait to close the gate. 
 | 
boolean | 
close(long cMillis)
Close the gate. 
 | 
com.oracle.common.util.Sentry<R> | 
enter()
Wait to enter the gate. 
 | 
boolean | 
enter(long cMillis)
Enter the gate. 
 | 
void | 
exit()
Exit the gate. 
 | 
boolean | 
isClosed()
Determine if any thread has closed the gate and continues to hold exclusive access. 
 | 
boolean | 
isClosedByCurrentThread()
Determine if the calling thread has closed the gate and continues
 to hold exclusive access. 
 | 
boolean | 
isEnteredByCurrentThread()
Determines if the current thread has entered the gate and not yet exited. 
 | 
void | 
open()
Re-open the closed gate. 
 | 
String | 
toString() | 
protected long | 
waitForOpen(ThreadGateLite.Bar bar,
           long cMillis)
Wait for notification that the bar has been lifted
 completely, i.e. all re-entrant barEntry calls were matched. 
 | 
protected final com.oracle.common.util.Sentry<R> f_exitSentry
protected final com.oracle.common.util.Sentry<R> f_openSentry
public ThreadGateLite()
public ThreadGateLite(R resource)
resource - the resourcepublic com.oracle.common.util.Sentry<R> close()
com.oracle.common.util.Gateclose in interface com.oracle.common.util.Gate<R>Gate.open().public boolean close(long cMillis)
Gate.open() method.close in interface com.oracle.common.util.Gate<R>cMillis - maximum number of milliseconds to wait;
                 pass -1 to wait indefinitely or 0 to return immediatelypublic com.oracle.common.util.Sentry<R> enter()
com.oracle.common.util.Gateenter in interface com.oracle.common.util.Gate<R>Gate.exit().public boolean enter(long cMillis)
Gate.exit() method.enter in interface com.oracle.common.util.Gate<R>cMillis - maximum number of milliseconds to wait;
                 pass -1 to wait indefinitely or 0 to return immediatelypublic void exit()
Gate.enter() method.exit in interface com.oracle.common.util.Gate<R>public boolean isClosedByCurrentThread()
isClosedByCurrentThread in interface com.oracle.common.util.Gate<R>public boolean isClosed()
isClosed in interface com.oracle.common.util.Gate<R>public boolean isEnteredByCurrentThread()
isEnteredByCurrentThread in interface com.oracle.common.util.Gate<R>public void open()
open in interface com.oracle.common.util.Gate<R>public boolean barEntry(long cMillis)
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()
     }
 barEntry in interface com.oracle.common.util.Gate<R>cMillis - maximum number of milliseconds to wait;
                pass -1 for forever or 0 for no waitprotected long waitForOpen(ThreadGateLite.Bar bar, long cMillis)
open().bar - the bar that needs to be lifted for this thread
                 to proceed (cannot be null)cMillis - time to wait or -1 for unlimited waitprotected long adjustWaitTime(long cMillis,
                              long ldtStart)
cMillis - the total time allotted for an operationldtStart - the start of the time interval that have passed