Class CommonIterator<TIterator, TIteratorType, TNativeIterator>
A common class for all iterators
public abstract class CommonIterator<TIterator, TIteratorType, TNativeIterator> : IGenericSerDesFactoryApplier, IEnumerable<TIteratorType>, IEnumerable, IAsyncEnumerable<TIteratorType>, IDisposable, IAsyncDisposable, IKNetInnerReference<TNativeIterator> where TIterator : CommonIterator<TIterator, TIteratorType, TNativeIterator>, new() where TNativeIterator : class, IDisposable
Type Parameters
TIteratorThe class implementing CommonIterator<TIterator, TIteratorType, TNativeIterator>
TIteratorTypeThe return Type of IEnumerable<T> and IAsyncEnumerable<T>
TNativeIteratorThe underlying native iterator
- Inheritance
-
CommonIterator<TIterator, TIteratorType, TNativeIterator>
- Implements
-
IEnumerable<TIteratorType>IAsyncEnumerable<TIteratorType>IKNetInnerReference<TNativeIterator>
- Derived
Fields
ObjectPool
Pool of objects managed from JCOBridgeObjectPool<T>
protected static readonly JCOBridgeObjectPool<TIterator> ObjectPool
Field Value
- JCOBridgeObjectPool<TIterator>
_disposed
Stores the disposed status
protected volatile int _disposed
Field Value
Properties
Factory
Returns the current IGenericSerDesFactory
protected IGenericSerDesFactory Factory { get; }
Property Value
InnerReference
The underlying inner reference used from KNet object instance
public TNativeIterator InnerReference { get; }
Property Value
- TNativeIterator
UsePrefetch
Used to get or set the type of enumerator to retrieve, default is with prefetch if the platform accept it
public bool UsePrefetch { get; set; }
Property Value
Methods
CheckDisposed()
Test if this instance was disposed
protected void CheckDisposed()
Exceptions
- ObjectDisposedException
When this instance was disposed
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
Implements the pattern described in https://learn.microsoft.com/en-en/dotnet/standard/garbage-collection/implementing-dispose
protected virtual void Dispose(bool disposing)
Parameters
disposingboolThe disposing parameter is a bool that indicates whether the method call comes from a Dispose() method (its value is true) or from a finalizer (its value is false)
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
GetAsyncEnumerator(CancellationToken)
Returns an enumerator that iterates asynchronously through the collection.
public IAsyncEnumerator<TIteratorType> GetAsyncEnumerator(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA CancellationToken that may be used to cancel the asynchronous iteration.
Returns
- IAsyncEnumerator<TIteratorType>
An enumerator that can be used to iterate asynchronously through the collection.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<TIteratorType> GetEnumerator()
Returns
- IEnumerator<TIteratorType>
An enumerator that can be used to iterate through the collection.
GetEnumerator(bool, bool, CancellationToken)
Internally gets the IEnumerable<T> or IAsyncEnumerable<T>
protected abstract object GetEnumerator(bool isAsync, bool usePrefetch, CancellationToken cancellationToken = default)
Parameters
isAsyncbooltrue if requesting an IAsyncEnumerator<T>
usePrefetchbooltrue if requesting prefetch behavior
cancellationTokenCancellationTokenThe CancellationToken to be used in IAsyncEnumerator<T>
Returns
Setup(IGenericSerDesFactory, TNativeIterator, bool)
protected void Setup(IGenericSerDesFactory factory, TNativeIterator iterator, bool fromPool)
Parameters
factoryIGenericSerDesFactoryiteratorTNativeIteratorfromPoolbool
ToIEnumerator(bool)
Returns an IEnumerator<T> of TIteratorType
public IEnumerator<TIteratorType> ToIEnumerator(bool usePrefetch = true)
Parameters
usePrefetchbooltrue to return an IEnumerator<T> making preparation of
TIteratorTypein parallel
Returns
- IEnumerator<TIteratorType>
An IEnumerator<T> of
TIteratorType
Remarks
usePrefetch is not considered with .NET 6 and .NET Framework