void cancel_enter()

in Source/Shared/arcana/scheduling/state_machine.h [91:113]


        void cancel_enter(abstract_state_machine_state& state)
        {
            std::optional<task_completion_source<void, std::error_code>> enter;
            {
                std::lock_guard<std::mutex> guard{ m_mutex };

                auto found = m_states.find(&state);
                if (found == m_states.end())
                {
                    return;
                }

                if (found->second.StateEntered->completed())
                {
                    return;
                }

                enter = found->second.StateEntered;
                m_states.erase(found);
            }

            enter->complete(make_unexpected(std::make_error_code(std::errc::operation_canceled)));
        }