.. index:: pair: class; EE::UI::UIThreadObservation .. _doxid-class_e_e_1_1_u_i_1_1_u_i_thread_observation: template class EE::UI::UIThreadObservation ========================================== .. toctree:: :hidden: struct_EE_UI_UIThreadObservation_SourceConnection.rst struct_EE_UI_UIThreadObservation_SourceConnectionBase.rst struct_EE_UI_UIThreadObservation_State.rst Overview ~~~~~~~~ Scoped non-blocking delivery of observable changes to the :ref:`UI ` thread. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include template class UIThreadObservation { public: // typedefs typedef std::function`&, const T&)> :target:`Callback`; // structs template struct :ref:`SourceConnection`; struct :ref:`SourceConnectionBase`; struct :ref:`State`; // construction :target:`UIThreadObservation`(); :target:`UIThreadObservation`(const UIThreadObservation&); :target:`UIThreadObservation`(UIThreadObservation&&); template :ref:`UIThreadObservation`(Source& source, :ref:`Node`& scheduler, :ref:`UIWidget`& endpoint, :ref:`Callback` callback); // methods UIThreadObservation& :target:`operator=`(const UIThreadObservation&); UIThreadObservation& :target:`operator=`(UIThreadObservation&&); void :ref:`disconnect`(); :ref:`operator bool`() const; }; .. _details-class_e_e_1_1_u_i_1_1_u_i_thread_observation: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Scoped non-blocking delivery of observable changes to the :ref:`UI ` thread. The scheduler must outlive this connection and is normally the owning :ref:`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 :ref:`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 ------------ .. index:: pair: function; UIThreadObservation .. _doxid-class_e_e_1_1_u_i_1_1_u_i_thread_observation_1a21bcb2da7a9632aef4ead718b78a38ae: .. ref-code-block:: cpp :class: doxyrest-title-code-block template UIThreadObservation(Source& source, :ref:`Node`& scheduler, :ref:`UIWidget`& endpoint, :ref:`Callback` callback) Observes ``source`` and queues ``callback`` on ``scheduler's`` :ref:`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 ------- .. index:: pair: function; disconnect .. _doxid-class_e_e_1_1_u_i_1_1_u_i_thread_observation_1ad6e1048bbf38fc87d2fbedf76da856b7: .. ref-code-block:: cpp :class: doxyrest-title-code-block void disconnect() Stops future delivery and invalidates already queued callbacks. Synchronize with the source producer before calling this; see the class thread-safety notes. .. index:: pair: function; operator bool .. _doxid-class_e_e_1_1_u_i_1_1_u_i_thread_observation_1a57a899aa2745e8fdae0ef6b5a773126c: .. ref-code-block:: cpp :class: doxyrest-title-code-block operator bool() const .. rubric:: Returns: Whether the source is connected and the endpoint remains alive.