-
Notifications
You must be signed in to change notification settings - Fork 5
ConcurrentEnumerator
huggins edited this page May 10, 2023
·
1 revision
Houses functionality to implement thread safe concurrent enumerators. Utilized in the ConcurrentList class.
public class ConcurrentEnumerator<T>
: IEnumerator<T>
Access | Type | Name | Description | |
---|---|---|---|---|
Private | readonly | List<T> | _inner | The enumerator that is thread safe. |
Private | readonly | ReaderWriterLockSlim | _lock | The lock to verify the enumerator is not access by multiple threads simultaneously. |
Public | T | Current | Gets the element in the collection at the current position of the enumerator. | |
object | IEnumerator.Current | Gets the element in the collection at the current position of the enumerator. |
Access | Name | Description |
---|---|---|
Public | ConcurrentEnumerator(IEnumerable<T> inner, ReaderWriterLockSlim @lock) | Initializes a concurrent enumerator for the specified list. |
Access | Return | Name | Description | |
---|---|---|---|---|
Public | void | Dispose() | Releases all resources used by the _lock variable. | |
Public | bool | MoveNext() | Advances the enumerator to the next element of the collection. | |
Public | void | Reset() | Sets the enumerator to its initial position, which is before the first element in the collection. |
private readonly IEnumerator<T> _inner
The enumerator that is thread safe.
private readonly ReaderWriterLockSlim _lock
The lock to verify the list is not access by multiple threads simultaneously.
public T Current
Gets the element in the collection at the current position of the enumerator.
object IEnumerator.Current
Gets the element in the collection at the current position of the enumerator.
ConcurrentEnumerator()
Initializes a concurrent enumerator for the specified list.
public void Dispose()
Releases all resources used by the _lock variable.
public bool MoveNext()
Advances the enumerator to the next element of the collection.
Returns |
---|
Whether or not the enumerator was successfully advanced to the next element. |
public void Reset()
Sets the enumerator to its initial position, which is before the first element in the collection.