A shared variable that can be used in a parallel region. This allows for a variable to be declared inside of a parallel region that is shared among all threads, which has some nice use cases.
More...
|
| Shared (string name, T value) |
| Creates a new shared variable with the given name and value. Must be called from all threads in the parallel region. Acts as a barrier. More...
|
|
void | Dispose () |
| Clears the shared variable from memory. Must be called from all threads in the parallel region. Acts as a barrier. More...
|
|
virtual void | Dispose (bool disposing) |
| Clears the shared variable from memory. Virtual implementation for IDisposable interface. More...
|
|
void | Set (T value) |
| Sets the value of the shared variable. Is not thread-safe, so user must ensure thread safety. More...
|
|
T | Get () |
| Gets the value of the shared variable. More...
|
|
|
static Dictionary< string, dynamic > | shared = new Dictionary<string, dynamic>() |
| The shared variables. More...
|
|
|
bool | Disposed [get, private set] |
| Whether or not the shared variable has been disposed. More...
|
|
A shared variable that can be used in a parallel region. This allows for a variable to be declared inside of a parallel region that is shared among all threads, which has some nice use cases.
Factory class for Shared<T>
- Template Parameters
-
T | The type of the shared variable. |
◆ Shared()
Creates a new shared variable with the given name and value. Must be called from all threads in the parallel region. Acts as a barrier.
- Parameters
-
name | Name of the shared variable. |
value | Initial starting value of the shared variable. |
◆ Create< T >()
Factory method for creating shared variables.
- Template Parameters
-
T | The type of the shared variable to create. |
- Parameters
-
name | The name of the shared variable. |
value | The value of the shared variable. |
- Returns
- A Shared object.
◆ Dispose() [1/2]
Clears the shared variable from memory. Must be called from all threads in the parallel region. Acts as a barrier.
◆ Dispose() [2/2]
Clears the shared variable from memory. Virtual implementation for IDisposable interface.
- Parameters
-
disposing | Whether or not to dispose of the shared variable. |
◆ Get()
Gets the value of the shared variable.
- Returns
- The value of the shared variable.
◆ operator T()
Gets the value of the shared variable.
- Parameters
-
shared | The shared variable to get the value from. |
◆ Set()
Sets the value of the shared variable. Is not thread-safe, so user must ensure thread safety.
- Parameters
-
value | The new value of the shared variable. |
◆ name
The name of the shared variable.
◆ shared
Dictionary<string, dynamic> DotMP.Shared< T >.shared = new Dictionary<string, dynamic>() |
|
staticprotected |
◆ Disposed
Whether or not the shared variable has been disposed.
The documentation for this class was generated from the following file: