MCPcopy Create free account
hub / github.com/David-Haim/concurrencpp / coroutine_handle_functor

Class coroutine_handle_functor

source/task.cpp:17–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15namespace concurrencpp::details {
16 namespace {
17 class coroutine_handle_functor {
18
19 private:
20 coroutine_handle<void> m_coro_handle;
21
22 public:
23 coroutine_handle_functor() noexcept : m_coro_handle() {}
24
25 coroutine_handle_functor(const coroutine_handle_functor&) = delete;
26 coroutine_handle_functor& operator=(const coroutine_handle_functor&) = delete;
27
28 coroutine_handle_functor(coroutine_handle<void> coro_handle) noexcept : m_coro_handle(coro_handle) {}
29
30 coroutine_handle_functor(coroutine_handle_functor&& rhs) noexcept : m_coro_handle(std::exchange(rhs.m_coro_handle, {})) {}
31
32 ~coroutine_handle_functor() noexcept {
33 if (static_cast<bool>(m_coro_handle)) {
34 m_coro_handle.destroy();
35 }
36 }
37
38 void execute_destroy() noexcept {
39 auto coro_handle = std::exchange(m_coro_handle, {});
40 coro_handle();
41 }
42
43 void operator()() noexcept {
44 execute_destroy();
45 }
46 };
47 } // namespace
48
49} // namespace concurrencpp::details

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected