Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::gpu::browser::BrowserDeviceRequest Class Reference

A request for a browser GPU device, in progress. More...

#include "donner/gpu/browser/BrowserDevice.h"

Public Member Functions

 BrowserDeviceRequest (BrowserDeviceRequest &&other) noexcept
 Move constructor.
BrowserDeviceRequest & operator= (BrowserDeviceRequest &&other) noexcept
 Move assignment.
 BrowserDeviceRequest (const BrowserDeviceRequest &)=delete
BrowserDeviceRequest & operator= (const BrowserDeviceRequest &)=delete
 ~BrowserDeviceRequest ()
 Destructor; abandons the request and releases the bridge if the device was never taken.
BrowserDeviceRequestState state () const
 How far the request has progressed. Polled; the browser settles it asynchronously.
RcString error () const
 Why the request failed, when state reports a failure. Empty otherwise.
BrowserDeviceRequestState settle (double timeoutSeconds)
 Waits for the browser to settle the request, for at most timeoutSeconds.
Result< std::unique_ptr< BrowserDevice > > take (std::shared_ptr< DeviceLostState > lostState=nullptr) &&
 Takes the device, consuming the request.

Static Public Member Functions

static BrowserDeviceRequest Begin (std::unique_ptr< BrowserBridge > bridge)
 Asks the browser for a device over bridge and returns the request.

Detailed Description

A request for a browser GPU device, in progress.

A browser hands over a device through promises it settles on its own schedule, so acquiring one is not something a constructor can report. The request is begun, polled until it settles, and then either yields a device or says why it will not. Nothing may be built on the bridge while the request is still pending.

Constructor & Destructor Documentation

◆ BrowserDeviceRequest()

donner::gpu::browser::BrowserDeviceRequest::BrowserDeviceRequest ( BrowserDeviceRequest && other)
noexcept

Move constructor.

Parameters
otherRequest to move from.

Member Function Documentation

◆ Begin()

BrowserDeviceRequest donner::gpu::browser::BrowserDeviceRequest::Begin ( std::unique_ptr< BrowserBridge > bridge)
static

Asks the browser for a device over bridge and returns the request.

A bridge that refuses to begin - a context that does not own the device, or one with no GPU service reachable at all - produces a request that is already failed, with error saying why. Reporting it that way rather than as a separate failure channel means a caller writes one settled-state check instead of two, and cannot handle the early refusal differently from the late one by accident.

Parameters
bridgeBridge to the browser's GPU service; the request takes ownership.

◆ operator=()

BrowserDeviceRequest & donner::gpu::browser::BrowserDeviceRequest::operator= ( BrowserDeviceRequest && other)
noexcept

Move assignment.

Parameters
otherRequest to move from.

◆ settle()

BrowserDeviceRequestState donner::gpu::browser::BrowserDeviceRequest::settle ( double timeoutSeconds)

Waits for the browser to settle the request, for at most timeoutSeconds.

A browser settles the request by running a promise callback, which cannot happen while this thread holds the event loop, so the wait hands the thread to the browser in short slices and looks again after each rather than resting on it.

Parameters
timeoutSecondsLongest to wait, in seconds; a value that is not positive looks once.
Returns
The state the request reached, which is BrowserDeviceRequestState::Pending when the budget ran out first.

◆ take()

Result< std::unique_ptr< BrowserDevice > > donner::gpu::browser::BrowserDeviceRequest::take ( std::shared_ptr< DeviceLostState > lostState = nullptr) &&

Takes the device, consuming the request.

Fails closed unless state reports BrowserDeviceRequestState::Ready, so a caller that skipped the wait gets a named error instead of a device that does not exist yet.

Parameters
lostStateLoss condition to share with the other devices over the same browser device, or null for one of the device's own. The device declares a loss the browser reports into it.

The documentation for this class was generated from the following file: