Table of Contents

Interface IAsyncEnvViewer

Namespace
Gym.Environments
Assembly
Gym.dll

A viewer that also renders asynchronously (DR-85): RenderAsync(NDArray, CancellationToken) and CloseAsync() complete once the UI has taken the frame or closed the window, without blocking the caller's thread. The same factory creates it as any viewer; an inherently asynchronous env checks for this interface and awaits it, and falls back to the synchronous Render(NDArray) otherwise (RenderAsync(IEnvViewer, NDArray, CancellationToken) does both).

public interface IAsyncEnvViewer : IEnvViewer, IDisposable
Inherited Members
Extension Methods

Methods

CloseAsync()

Closes the window without blocking; completes once it is closed.

ValueTask CloseAsync()

Returns

ValueTask

The pending close.

RenderAsync(NDArray, CancellationToken)

Shows frame without blocking; completes once the viewer has its own copy of it.

ValueTask RenderAsync(NDArray frame, CancellationToken cancellationToken = default)

Parameters

frame NDArray

The frame, (H, W, 3) uint8; it stays the caller's, and must not change before the task completes.

cancellationToken CancellationToken

Cancels the wait for the UI; a cancelled render may still show the frame.

Returns

ValueTask

The pending render.

Exceptions

ArgumentNullException

Thrown when frame is null (the built-in viewers).

ArgumentException

Thrown for a frame that is not (H, W, 3) (the built-in viewers).

OperationCanceledException

Thrown through the task when cancellationToken is cancelled first.