Table of Contents

Class EnvViewerExtensions

Namespace
Gym.Environments
Assembly
Gym.dll

The asynchronous path for any IEnvViewer (DR-85): awaits an IAsyncEnvViewer's own methods, and runs a synchronous viewer's on the caller's thread, so an asynchronous env writes one call for both.

public static class EnvViewerExtensions
Inheritance
EnvViewerExtensions
Inherited Members

Methods

CloseAsync(IEnvViewer)

Closes the window: CloseAsync() when the viewer has it, else Close() on the calling thread.

public static ValueTask CloseAsync(this IEnvViewer viewer)

Parameters

viewer IEnvViewer

The viewer.

Returns

ValueTask

The close: pending for an asynchronous viewer, completed for a synchronous one.

Exceptions

ArgumentNullException

Thrown when viewer is null.

RenderAsync(IEnvViewer, NDArray, CancellationToken)

Shows frame: RenderAsync(NDArray, CancellationToken) when the viewer has it, else Render(NDArray) on the calling thread, which completes synchronously (no thread-pool hop).

public static ValueTask RenderAsync(this IEnvViewer viewer, NDArray frame, CancellationToken cancellationToken = default)

Parameters

viewer IEnvViewer

The viewer.

frame NDArray

The frame, (H, W, 3) uint8; it stays the caller's.

cancellationToken CancellationToken

Cancels before a synchronous render, or the wait of an asynchronous one.

Returns

ValueTask

The render: pending for an asynchronous viewer, completed for a synchronous one.

Exceptions

ArgumentNullException

Thrown when viewer is null.

OperationCanceledException

Thrown, or through the task, when cancellationToken is cancelled first.

ArgumentException

Thrown, or through the task, by the viewer for a frame it cannot show.