GuardedState

The editable state of an environment or a sun driver, behind one lock (2026-10-16).

template <typename State> class construct::rendering::GuardedState

In the namespace construct::rendering. Declared in src/libs/libconstruct/construct/rendering/GuardedState.hpp.

Detailed description

The GUI thread writes an environment (a swatch, a scene load, the palette) while a render worker reads it for its uniforms and its lights. Without a lock a frame could read a torn color, or a key light from one state and a rim light from another, and a replaced sun driver could be deleted under the reader.

The rule is one lock and one snapshot: a reader calls snapshot() ONCE and derives everything of its read from that copy; a writer changes the state inside update(). Keep the State a plain value (colors, numbers, implicitly shared Qt containers, shared pointers), so a copy is cheap and holds nothing that the writer can change after the copy.

In this section