|
|
| GeodePerDevice (const GeodePerDevice &)=delete |
|
GeodePerDevice & | operator= (const GeodePerDevice &)=delete |
| | GeodePerDevice (GeodePerDevice &&other) noexcept=default |
| | Construct by moving another instance's state.
|
| GeodePerDevice & | operator= (GeodePerDevice &&other) noexcept=default |
| | Replace this object's state by moving another instance.
|
| T & | forDevice (const GeodeDeviceKey &device) |
| | The entry for device, creating an empty one when it has none. Drops nothing.
|
| size_t | dropGone () |
| | Drops the entries of contexts that are gone.
|
| T * | find (uint64_t deviceId) |
| | The entry for the device deviceId, or null when it has none.
|
| template<typename Fn> |
| void | forEach (Fn &&fn) |
| | Calls fn with every device's entry.
|
|
size_t | size () const |
| | Number of devices with an entry.
|
template<typename T>
class donner::geode::GeodePerDevice< T >
One T per device that draws a document, kept on the document.
A document can be drawn by renderers on several devices - a render worker's and a UI thread's thumbnail pass, say. State one device builds for the document holds that device's handles, so a second device must neither reuse it nor replace it: replacing it would destroy the first device's state on the second device's thread and make the first device rebuild it on its next frame. Each device gets its own entry instead. An entry whose context has gone away (its retirement is closed or destroyed) stays until dropGone drops it; looking entries up never drops one, so the owner decides where that happens and can do everything that goes with it there. Dropping is safe on any thread: the entry's state hands its handles to a closed retirement, which keeps them, or, once that retirement is destroyed, drops them after their device is gone, when releasing them does nothing.
A document drops gone devices' entries in one place: when its own entry for a gone device is dropped, it drops that device's entries from every per-entity component that holds one of these. A new per-entity component type holding one must be added to that sweep (see DocumentPerDeviceComponents in RendererGeode.cc), or a gone device's slots would keep its slabs alive.
Values are held by pointer, so a reference to one stays valid while other devices' entries come and go.
- Template Parameters
-
| T | Per-device state; default-constructible. |