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
viewerIEnvViewerThe viewer.
Returns
- ValueTask
The close: pending for an asynchronous viewer, completed for a synchronous one.
Exceptions
- ArgumentNullException
Thrown when
vieweris 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
viewerIEnvViewerThe viewer.
frameNDArrayThe frame,
(H, W, 3)uint8; it stays the caller's.cancellationTokenCancellationTokenCancels 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
vieweris null.- OperationCanceledException
Thrown, or through the task, when
cancellationTokenis cancelled first.- ArgumentException
Thrown, or through the task, by the viewer for a frame it cannot show.