.. index:: pair: class; EE::detail::TaskSharedState .. _doxid-class_e_e_1_1detail_1_1_task_shared_state: template class EE::detail::TaskSharedState ========================================== .. toctree:: :hidden: Overview ~~~~~~~~ State shared by one Task and the copies of its TaskResolver. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include template class TaskSharedState { public: // typedefs typedef std::conditional_t, :ref:`TaskVoidValue`, T> :target:`Value`; typedef :ref:`SmallUniqueFunction` :target:`Continuation`; // methods void :target:`retain`(); void :target:`release`(); void :target:`retainResolver`(); bool :ref:`releaseResolver`(); :ref:`TaskState` :target:`state`() const; template bool :target:`resolve`(Args&&... args); bool :ref:`abandon`(); void :ref:`attach`(:ref:`Continuation` continuation); :ref:`TaskState` :target:`wait`(); template :ref:`TaskState` :target:`waitFor`(const std::chrono::duration& timeout); :ref:`Value`& :ref:`value`(); }; .. _details-class_e_e_1_1detail_1_1_task_shared_state: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ State shared by one Task and the copies of its TaskResolver. Reference counting is intrusive so that continuations can re-acquire ownership from the plain reference they receive (needed to keep the value alive while a continuation is queued on an executor) and so that every task costs exactly one allocation. Resolver copies are counted apart, so the task is abandoned when the last resolver goes away, whoever else still holds the state. Methods ------- .. index:: pair: function; releaseResolver .. _doxid-class_e_e_1_1detail_1_1_task_shared_state_1a4ba19defb8668c9696b6db60bd4516db: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool releaseResolver() .. rubric:: Returns: True if the last resolver was released. .. index:: pair: function; abandon .. _doxid-class_e_e_1_1detail_1_1_task_shared_state_1a132ffb468eb0e52b844440d69fd97ae6: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool abandon() .. rubric:: Returns: True if this call moved the state from Pending to Abandoned. .. index:: pair: function; attach .. _doxid-class_e_e_1_1detail_1_1_task_shared_state_1a7a32976a5f357a6ffa88a0202af61249: .. ref-code-block:: cpp :class: doxyrest-title-code-block void attach(:ref:`Continuation` continuation) Stores the continuation, or runs it immediately if the state is already terminal. Never invokes user code while holding the mutex. .. index:: pair: function; value .. _doxid-class_e_e_1_1detail_1_1_task_shared_state_1a78fff8ecec39e5623b16187de4aa55f4: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Value`& value() Only valid once Ready, and only from the single consumer.