template class EE::UI::UIThreadObservation¶
Overview¶
Scoped non-blocking delivery of observable changes to the UI thread. More…
#include <uiobservedelivery.hpp> template <typename T> class UIThreadObservation { public: // typedefs typedef std::function<void(UIWidget&, const T&)> Callback; // structs template <typename Connection> struct SourceConnection; struct SourceConnectionBase; struct State; // construction UIThreadObservation(); UIThreadObservation(const UIThreadObservation&); UIThreadObservation(UIThreadObservation&&); template <typename Source> UIThreadObservation(Source& source, Node& scheduler, UIWidget& endpoint, Callback callback); // methods UIThreadObservation& operator=(const UIThreadObservation&); UIThreadObservation& operator=(UIThreadObservation&&); void disconnect(); operator bool() const; };
Detailed Documentation¶
Scoped non-blocking delivery of observable changes to the UI thread.
The scheduler must outlive this connection and is normally the owning UISceneNode. The endpoint widget is not retained; queued work becomes a no-op after it closes. Source mutation remains the producer’s synchronization responsibility because ObservableValue itself is single-threaded. In particular, construct and disconnect this observation only while the producer is stopped or otherwise synchronized; observer registration and removal must not race source mutation.
Construction¶
template <typename Source> UIThreadObservation(Source& source, Node& scheduler, UIWidget& endpoint, Callback callback)
Observes source and queues callback on scheduler's UI thread.
Delivery preserves source notification order. The callback receives the endpoint only while it remains alive. Keep the returned observation alive and ensure the scheduler outlives it.
Methods¶
void disconnect()
Stops future delivery and invalidates already queued callbacks.
Synchronize with the source producer before calling this; see the class thread-safety notes.
operator bool() const
Returns:
Whether the source is connected and the endpoint remains alive.