Oracle® Coherence .NET API Reference Release 3.7.1
E22844-03
Assembly: Coherence (in Coherence.dll) Version: 3.7.1.23 (3.7.1.23)
System..::.Object
Tangosol.Util..::.ThreadGate
E22844-03
Use this class in cases that large numbers of threads can operate
concurrently with an additional requirement that all threads be
blocked for certain operations.
Namespace:
Tangosol.UtilAssembly: Coherence (in Coherence.dll) Version: 3.7.1.23 (3.7.1.23)
Syntax
| C# |
|---|
public class ThreadGate : Gate |
Remarks
The algorithm is based on a gate concept, allowing threads in
Enter(Int64) and out Exit()()(), but occasionally
shutting the gate Close(Int64) such that other threads cannot
enter and exit. However, since threads may "be inside", the gate
cannot fully close until they leave Exit()()(). Once all
threads are out, the gate is closed, and can be re-opened
Open()()() or permanently closed Destroy()()().
Each call to Enter requires a corresponding call to Exit. For example, the following would ensure proper clean-up using a ThreadGate:
gate.Enter();
try
{
...
}
finally
{
gate.Exit();
}
Similarly, each call to Close should be matched with a call to Open, unless the gate is being destroyed:
gate.Close();
try
{
...
}
finally
{
gate.Open();
}
or:
gate.Close();
gate.Destroy();
The Enter/Exit calls can be nested; the same thread can invoke Enter multiple times as long as Exit is invoked a corresponding number of times. The Close/Open calls work in the same manner. Lastly, the thread that closes the gate may continue to Enter/Exit the gate even when it is closed since that thread has exclusive control of the gate.
Cameron Purdy 2003.05.26Mark Falco 2007.04.27Ana Cikic 2006.08.29Coherence 2.2
Inheritance Hierarchy
Tangosol.Util..::.ThreadGate