Table of Contents

Class CommonIterator<TIterator, TIteratorType, TNativeIterator>

Namespace
MASES.KNet.Streams.State
Assembly
MASES.KNet.dll

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

TIterator

The class implementing CommonIterator<TIterator, TIteratorType, TNativeIterator>

TIteratorType

The return Type of IEnumerable<T> and IAsyncEnumerable<T>

TNativeIterator

The 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

int

Properties

Factory

Returns the current IGenericSerDesFactory

protected IGenericSerDesFactory Factory { get; }

Property Value

IGenericSerDesFactory

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

bool

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)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

The 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

ValueTask

GetAsyncEnumerator(CancellationToken)

Returns an enumerator that iterates asynchronously through the collection.

public IAsyncEnumerator<TIteratorType> GetAsyncEnumerator(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A 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

isAsync bool

true if requesting an IAsyncEnumerator<T>

usePrefetch bool

true if requesting prefetch behavior

cancellationToken CancellationToken

The CancellationToken to be used in IAsyncEnumerator<T>

Returns

object

An IEnumerable<T> or IAsyncEnumerable<T>

Setup(IGenericSerDesFactory, TNativeIterator, bool)

protected void Setup(IGenericSerDesFactory factory, TNativeIterator iterator, bool fromPool)

Parameters

factory IGenericSerDesFactory
iterator TNativeIterator
fromPool bool

ToIEnumerator(bool)

Returns an IEnumerator<T> of TIteratorType

public IEnumerator<TIteratorType> ToIEnumerator(bool usePrefetch = true)

Parameters

usePrefetch bool

true to return an IEnumerator<T> making preparation of TIteratorType in parallel

Returns

IEnumerator<TIteratorType>

An IEnumerator<T> of TIteratorType

Remarks

usePrefetch is not considered with .NET 6 and .NET Framework