#ifndef COROUTINES_INCLUDE_CORO_INTERNAL_COTEST_CRF_LAUNCH_H_ #define COROUTINES_INCLUDE_CORO_INTERNAL_COTEST_CRF_LAUNCH_H_ #include #include #include #include #include "cotest-crf-core.h" #include "cotest-crf-mock.h" #include "cotest-crf-payloads.h" #include "cotest-util-types.h" namespace testing { namespace crf { // ------------------ Classes ------------------ class MockRoutingSession; class InteriorEventSession; template class InteriorSignatureMockCS; class InteriorLaunchSessionBase; template class InteriorLaunchSession; class TestCoroutine; class LaunchCoroutine final : public CoroutineBase, public MockSource, public std::enable_shared_from_this { public: LaunchCoroutine(std::string name_); ~LaunchCoroutine(); void Body(); ReplyPair ReceiveMessage(std::unique_ptr &&to_node) final; ReplyPair IterateServer(std::unique_ptr &&to_coro); std::shared_ptr CreateMockRoutingSession(UntypedMockerPointer mocker_, UntypedMockObjectPointer mock_obj_, const char *name_) final; std::shared_ptr TryGetCurrentLaunchSession(); std::shared_ptr TryGetCurrentLaunchSession() const; LaunchCoroutine *GetAsCoroutine() final; const LaunchCoroutine *GetAsCoroutine() const final; std::string DebugString() const final; private: std::weak_ptr current_launch_session; }; class LaunchCoroutinePool final : public virtual MessageNode { public: using PoolType = std::map>; LaunchCoroutine *TryGetUnusedLaunchCoro(); LaunchCoroutine *Allocate(std::string launch_text); std::shared_ptr FindActiveMockSource(); ReplyPair ReceiveMessage(std::unique_ptr &&to_node) final; std::string DebugString() const final; int CleanUp(); static LaunchCoroutinePool *GetInstance(); private: PoolType pool; }; } // namespace crf } // namespace testing #endif