.. index:: pair: class; EE::Scene::MainThreadLifetime .. _doxid-class_e_e_1_1_scene_1_1_main_thread_lifetime: template class EE::Scene::MainThreadLifetime ============================================ .. toctree:: :hidden: struct_EE_Scene_MainThreadLifetime_State.rst class_EE_Scene_MainThreadLifetime_WeakHandle.rst Gates main-thread callbacks with the lifetime of a non-owning object. The dispatcher and the guarded object must belong to the main thread. The dispatcher may be the guarded object itself, but it must otherwise outlive it. Worker threads may safely copy a :ref:`WeakHandle ` and call run(); callbacks queued before invalidation become no-ops once the object is destroyed. .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include template class MainThreadLifetime { public: // structs struct :ref:`State`; // classes class :ref:`WeakHandle`; // construction :target:`MainThreadLifetime`(T* object, :ref:`Node`* dispatcher); :target:`MainThreadLifetime`(const MainThreadLifetime&); :target:`~MainThreadLifetime`(); // methods MainThreadLifetime& :target:`operator=`(const MainThreadLifetime&); :ref:`WeakHandle` :target:`weakHandle`() const; void :target:`setDispatcher`(:ref:`Node`* dispatcher); void :target:`invalidate`(); };