Click or drag to resize

IGlobalCache Interface

Interface that defines a GlobalCache, a thread-safe repository of key value pairs to contain global data and signals to synchronize multi-threaded processing. GlobalCache elements are available throughout all phases of Data Conveyer processing. Element keys are of type string, values can be one of: int, DataTime, decimal, string or object.

GlobalCache elements must be defined using GlobalCacheElements configuration setting. During the process execution, element values can be updated, but no elements can be added/removed.

Signals, unlike elements, do not need to be declared; instead they are simply referred to in RaiseSignal(String), AwaitSignal(String)and AwaitSignalAsync(String) methods.

Caution note Caution
GlobalCache is exposed to concurrent access by multiple threads and therefore updates to its elements (such as TryReplace method) must be performed in a thread-safe manner. Data Conveyer makes no guarantees regarding a particular processing order. As a consequence, user code may need to address possible race conditions, for example by using AwaitCondition(FuncIGlobalCache, Boolean) method.

Namespace:  Mavidian.DataConveyer.Orchestrators
Assembly:  DataConveyer (in DataConveyer.dll) Version: 3.4.6+1324144ff7
Syntax
public interface IGlobalCache

The IGlobalCache type exposes the following members.

Properties
  NameDescription
Public propertyCount
Number of elements held. This value remains constant throughout execution of Data Conveyer process.
Public propertyElements
A collection of all elements held.
Public propertyItem
Retrieve the current value for a given key.
Top
Methods
  NameDescription
Public methodAwaitCondition
Wait for a given condition to be satisfied before returning. This method blocks the current thread until the provided function evaluates to true. Therefore, special care must be taken when defining the function (condition parameter) to avoid a deadlock condition.
Public methodAwaitConditionAsync
Asynchronously wait for a given condition to be satisfied. The returned task will not complete until the provided function evaluates to true. When called from an asynchronous method, this method allows synchronization of DataConveyer processing without thread blocking.
Public methodAwaitSignal
Wait for a given signal to be raised before returning. This method blocks the current thread until the given signal is raised. Therefore, special care must be taken to assure that the RaiseSignal(String) method is called on another thread, so that a deadlock condition is avoided.
Public methodAwaitSignalAsync
Asynchronously wait for a given signal to be raised. The returned task will not complete until the given signal is raised using the RaiseSignal(String) method. When called from an asynchronous method, this method allows synchronization of DataConveyer processing without thread blocking.
Public methodIncrementValue(String)
Add 1 to an integer value held in GlobalCache. This method is thread-safe.
Public methodIncrementValue(String, Int32)
Add a given number to an integer value held in GlobalCache. This method is thread-safe.
Public methodRaiseSignal
Raise a signal that another part (thread) of DataConveyer process might be waiting for. Once this method is called, any method held by either the AwaitSignal(String) or AwaitSignalAsync(String) method will continue execution.
Public methodReplaceValueTIn, TOut
Replace value for a given key based on a given calculation formula.
Public methodTryGet
Attempt to retrieve the current value for a given key.
Public methodTryReplace
Attempt to replace the value for a given key. This method is thread-safe. Note that there is no guarantee that any call to TryReplace method will succeed; it will fail (return false) if another thread changed the underlying value (oldValue). To guarantee a successful replacement, TryGet and TryReplace methods need to be called in a loop until TryReplace returns true. Alternatively, ReplaceValue method may be called, which executes such loop internally.
Top
See Also