.. index:: pair: class; EE::Scene::MainThreadExecutor .. _doxid-class_e_e_1_1_scene_1_1_main_thread_executor: class EE::Scene::MainThreadExecutor =================================== .. toctree:: :hidden: Overview ~~~~~~~~ :ref:`Executor ` that runs functions on the main (:ref:`UI `) thread. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class MainThreadExecutor: public :ref:`EE::Executor` { public: // construction :target:`MainThreadExecutor`(:ref:`Node`* dispatcher); :target:`MainThreadExecutor`(const MainThreadExecutor&); :target:`~MainThreadExecutor`(); // methods MainThreadExecutor& :target:`operator=`(const MainThreadExecutor&); virtual void :target:`execute`(:ref:`Function` function); void :ref:`shutdown`(); size_t :ref:`pending`() const; }; Inherited Members ----------------- .. ref-code-block:: cpp :class: doxyrest-overview-inherited-code-block public: // typedefs typedef :ref:`SmallUniqueFunction``> :ref:`Function`; // fields static constexpr std::size_t :ref:`FunctionInlineSize` = 64; // methods virtual void :ref:`execute`(:ref:`Function` function) = 0; .. _details-class_e_e_1_1_scene_1_1_main_thread_executor: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ :ref:`Executor ` that runs functions on the main (:ref:`UI `) thread. Functions are queued and drained in submission order by a single :ref:`Node::runOnMainThread() ` runnable per batch, so bursts of continuations cost one scheduled action. Execution is always deferred to the next scene update, even when :ref:`execute() ` is called from the main thread, which is what :ref:`Task::then() ` requires. The dispatcher node must outlive the executor, or :ref:`shutdown() ` must be called before the node is destroyed. Destroying the executor drops queued functions that have not run yet (releasing what they own, for example abandoning the tasks of the resolvers they hold). Methods ------- .. index:: pair: function; shutdown .. _doxid-class_e_e_1_1_scene_1_1_main_thread_executor_1aa22ebad83ffd478559f461afa1ebc46f: .. ref-code-block:: cpp :class: doxyrest-title-code-block void shutdown() Detaches the executor from its dispatcher node and drops the queued functions. Functions executed afterwards are dropped too. Call it before the dispatcher node is destroyed when work may still be executed on this executor (it must then outlive that work). .. index:: pair: function; pending .. _doxid-class_e_e_1_1_scene_1_1_main_thread_executor_1a3e24f5b4207c827e9d6b3f53acd6b739: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t pending() const .. rubric:: Returns: Number of functions waiting for the main thread.