Table of Contents

Class OpenCLEventPool

Namespace
DotCompute.Backends.OpenCL.Execution
Assembly
DotCompute.Backends.OpenCL.dll

Pool of OpenCL events for efficient reuse. Delegates to OpenCLEventManager for actual pooling and management. Provides a simplified interface for event acquisition with automatic cleanup.

public sealed class OpenCLEventPool : IAsyncDisposable
Inheritance
OpenCLEventPool
Implements
Inherited Members

Constructors

OpenCLEventPool(OpenCLEventManager)

Initializes a new instance of the OpenCLEventPool class.

public OpenCLEventPool(OpenCLEventManager manager)

Parameters

manager OpenCLEventManager

The event manager that handles the underlying event lifecycle.

Exceptions

ArgumentNullException

Thrown if manager is null.

Methods

AcquireAsync(EventProperties, CancellationToken)

Acquires an event from the pool with specified properties. Events are automatically returned to the pool when disposed.

public ValueTask<EventHandle> AcquireAsync(EventProperties properties, CancellationToken cancellationToken = default)

Parameters

properties EventProperties

Properties for the event (profiling, user event, etc.).

cancellationToken CancellationToken

Cancellation token for the async operation.

Returns

ValueTask<EventHandle>

A handle to the acquired event with RAII cleanup semantics.

Exceptions

ObjectDisposedException

Thrown if the pool has been disposed.

AcquireAsync(CancellationToken)

Acquires a simple event from the pool with default properties. Convenience method for non-profiling, non-user events.

public ValueTask<EventHandle> AcquireAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token for the async operation.

Returns

ValueTask<EventHandle>

A handle to the acquired event with RAII cleanup semantics.

Exceptions

ObjectDisposedException

Thrown if the pool has been disposed.

AcquireProfilingEventAsync(string?, CancellationToken)

Acquires an event with profiling enabled. Profiling events allow timing measurements but cannot be pooled.

public ValueTask<EventHandle> AcquireProfilingEventAsync(string? name = null, CancellationToken cancellationToken = default)

Parameters

name string

Optional descriptive name for the profiling event.

cancellationToken CancellationToken

Cancellation token for the async operation.

Returns

ValueTask<EventHandle>

A handle to the acquired profiling event with RAII cleanup semantics.

Exceptions

ObjectDisposedException

Thrown if the pool has been disposed.

DisposeAsync()

Asynchronously disposes the event pool and underlying manager. All active and pooled events are properly cleaned up.

public ValueTask DisposeAsync()

Returns

ValueTask

GetStatistics()

Gets comprehensive statistics about event usage and pool performance. Useful for monitoring and optimization.

public EventStatistics GetStatistics()

Returns

EventStatistics

Statistics snapshot showing pool hit rates, active events, etc.

Exceptions

ObjectDisposedException

Thrown if the pool has been disposed.