Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::geode::GeodePerDevice< T > Class Template Reference

One T per device that draws a document, kept on the document. More...

#include "donner/svg/renderer/geode/GeodePerDevice.h"

Public Member Functions

 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.

Detailed Description

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
TPer-device state; default-constructible.

Constructor & Destructor Documentation

◆ GeodePerDevice()

template<typename T>
donner::geode::GeodePerDevice< T >::GeodePerDevice ( GeodePerDevice< T > && other)
defaultnoexcept

Construct by moving another instance's state.

Parameters
otherSource object.

Member Function Documentation

◆ dropGone()

template<typename T>
size_t donner::geode::GeodePerDevice< T >::dropGone ( )
inline

Drops the entries of contexts that are gone.

Returns
Number of entries dropped.

◆ find()

template<typename T>
T * donner::geode::GeodePerDevice< T >::find ( uint64_t deviceId)
inline

The entry for the device deviceId, or null when it has none.

Parameters
deviceIdGeodeDevice::deviceId() of the device.

◆ forDevice()

template<typename T>
T & donner::geode::GeodePerDevice< T >::forDevice ( const GeodeDeviceKey & device)
inline

The entry for device, creating an empty one when it has none. Drops nothing.

Parameters
deviceDevice the entry belongs to.

◆ forEach()

template<typename T>
template<typename Fn>
void donner::geode::GeodePerDevice< T >::forEach ( Fn && fn)
inline

Calls fn with every device's entry.

Parameters
fnCallable taking T&.

◆ operator=()

template<typename T>
GeodePerDevice & donner::geode::GeodePerDevice< T >::operator= ( GeodePerDevice< T > && other)
defaultnoexcept

Replace this object's state by moving another instance.

Parameters
otherSource object.
Returns
This object after the move.

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