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::DeviceLostState Struct Reference

Sticky device-loss condition of one backend root. More...

#include "donner/gpu/DeviceLost.h"

Public Member Functions

void addLossRelease (std::weak_ptr< DeviceLossRelease > release)
 Registers release to run when this condition is declared, or runs it at once when it already has been.

Public Attributes

std::atomic< bool > lost {false}
 True once the device has been declared lost. Never reset. Publish it only through DeclareDeviceLost or DeclareDeviceLostAfterWaitTimeout, never by storing directly: the declaring call is what decides the attribution below, and a direct store silently opts out of that decision.
std::atomic< DeviceLostWaitSite > timedOutSite {DeviceLostWaitSite::None}
 Bounded wait that declared the loss, or None when the backend reported it. Only the call that wins the lost transition writes this, so an empty site is a positive statement ("no deadline expired first"), not an unwritten field.
std::atomic< int > timedOutElapsedMs {0}
 Wall time the timed-out wait spent before giving up, in milliseconds. Written before timedOutSite, which publishes it, so a reader that sees a site also sees that site's elapsed time. Zero while timedOutSite is None.
std::atomic< bool > attributionSettled {false}
 True after the winning declaration has published its attribution. Diagnostic readers must not freeze a first-loss record before this becomes true: a timeout sets lost first to win the declaration, then publishes its site and elapsed time.

Friends

bool DeclareDeviceLost (DeviceLostState &state)
 Declare state lost with no wait to attribute it to.
bool DeclareDeviceLostAfterWaitTimeout (DeviceLostState &state, DeviceLostWaitSite site, std::chrono::milliseconds elapsed)
 Declare state lost because a bounded wait at site gave up after elapsed.

Detailed Description

Sticky device-loss condition of one backend root.

Set exactly once, from either direction, so a driver-reported device-loss callback and a bounded wait exceeding its deadline converge on one observable condition. Held via shared_ptr by every party that needs to observe or publish it - each runtime device over the root, and a host embedder's own device-lost callback - because backend callbacks can outlive the object that registered them.

Member Function Documentation

◆ addLossRelease()

void donner::gpu::DeviceLostState::addLossRelease ( std::weak_ptr< DeviceLossRelease > release)

Registers release to run when this condition is declared, or runs it at once when it already has been.

Held weakly, so a release whose owner is gone is skipped rather than kept alive; registering one that is already held does nothing. Callable from any thread.

Parameters
releaseWhat the declaration must release.

◆ DeclareDeviceLost

bool DeclareDeviceLost ( DeviceLostState & state)
friend

Declare state lost with no wait to attribute it to.

For losses the backend reports: there is no deadline behind them, so timedOutSite stays None and says exactly that. The call that declares the loss runs every release registered with DeviceLostState::addLossRelease before it returns.

Parameters
stateShared device-lost record.
Returns
True when this call performed the false-to-true transition, so a caller can log the cause exactly once.

◆ DeclareDeviceLostAfterWaitTimeout

bool DeclareDeviceLostAfterWaitTimeout ( DeviceLostState & state,
DeviceLostWaitSite site,
std::chrono::milliseconds elapsed )
friend

Declare state lost because a bounded wait at site gave up after elapsed.

The attribution is written only when this call is the one that declares the loss. Two other writers reach the same flag and neither may claim the site: a later bounded wait, which gives up because the device is ALREADY hung (a consequence of the loss, never its cause), and the backend's device-lost callback, which has no wait to name. Deriving the claim from the flag's own transition covers both without a check-then-set window - reading the flag and then storing the site would let a driver-reported loss landing in between be relabelled as a wait timeout, which is the one misattribution an empty site exists to rule out.

Like DeclareDeviceLost, the declaring call runs every registered release before it returns, after the attribution is written, so whatever a release lets run sees the site.

Parameters
stateShared device-lost record.
siteWhich bounded wait gave up.
elapsedWall time that wait spent before giving up.
Returns
True when this call performed the false-to-true transition.

Member Data Documentation

◆ timedOutSite

std::atomic<DeviceLostWaitSite> donner::gpu::DeviceLostState::timedOutSite {DeviceLostWaitSite::None}

Bounded wait that declared the loss, or None when the backend reported it. Only the call that wins the lost transition writes this, so an empty site is a positive statement ("no deadline expired first"), not an unwritten field.

Written just after lost, so a reader sampling between the two sees a lost device with an empty site for the width of two stores. That reads as a driver-reported loss, which is wrong but self-correcting: the site settles immediately and the next sample carries it. Consumers that publish this pair should therefore key on its value changing rather than latching the first sample they see.


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