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. | |
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.
|
noexcept |
Move constructor.
| other | Request to move from. |
|
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.
| bridge | Bridge to the browser's GPU service; the request takes ownership. |
|
noexcept |
Move assignment.
| other | Request to move from. |
| 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.
| timeoutSeconds | Longest to wait, in seconds; a value that is not positive looks once. |
| 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.
| lostState | Loss 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. |