 | FastThreadLocalT Class |
IThreadLocal provides the engine with a way to store information that
is local to the instance and a the thread. While the CLR provides the
ThreadStatic attribute, it can only be applied to static variables;
some usage patterns in esper (such as statement-specific thread-specific
processing data) require that data be associated by instance and thread.
The CLR provides a solution to this known as LocalDataStoreSlot. It
has been documented that this method is slower than its ThreadStatic
counterpart, but it allows for instance-based allocation.
During recent testing it was determined that the LocalDataStoreSlot was
using an amount of time that seemed a bit excessive. We took some
snapshots of performance under the profiler. Using that information we
retooled the class to provide tight and fast access to thread-local
instance-specific data. The class is pretty tightly wound and takes a
few liberties in understanding how esper uses it. A ThreadStatic
variable is initialized for the IThreadLocal. This item is 'thread-local'
and contains an array of 'instance-specific' data. Indexing is done
when the IThreadLocal item is created. Under esper this results in roughly
one 'index' per statement. Changes to this model resulted in good cost
savings in the retrieval and acquisition of local data.
Inheritance HierarchySystemObject com.espertech.esper.compat.threading.threadlocalFastThreadLocalT
Namespace:
com.espertech.esper.compat.threading.threadlocal
Assembly:
NEsper.Compat (in NEsper.Compat.dll) Version: 8.0.0.0
Syntaxpublic sealed class FastThreadLocal<T> : IThreadLocal<T>,
IDisposable
Type Parameters
- T
[Missing <typeparam name="T"/> documentation for "T:com.espertech.esper.compat.threading.threadlocal.FastThreadLocal`1"]
The FastThreadLocalT type exposes the following members.
Constructors
Properties
| Name | Description |
---|
 | InstanceId |
Gets the instance id ... if you really must know.
|
 | Value |
Gets or sets the value.
|
Top
Methods
| Name | Description |
---|
 | ClearAll |
Clears all threads
|
 | Dispose |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
 | GetOrCreate |
Gets the data or creates it if not found.
|
 | Remove |
Resets the thread local instance.
|
Top
See Also