diff --git a/include/cppcoro/static_thread_pool.hpp b/include/cppcoro/static_thread_pool.hpp index 95ef3c50..d3927902 100644 --- a/include/cppcoro/static_thread_pool.hpp +++ b/include/cppcoro/static_thread_pool.hpp @@ -11,7 +11,16 @@ #include #include #include -#include + +#if __has_include() + #include + namespace cppcoro_coroutine = std; +#elif __has_include() + #include + namespace cppcoro_coroutine = std::experimental; +#else + #error "No coroutine header available" +#endif namespace cppcoro { @@ -38,7 +47,7 @@ namespace cppcoro schedule_operation(static_thread_pool* tp) noexcept : m_threadPool(tp) {} bool await_ready() noexcept { return false; } - void await_suspend(std::experimental::coroutine_handle<> awaitingCoroutine) noexcept; + void await_suspend(cppcoro_coroutine::coroutine_handle<> awaitingCoroutine) noexcept; void await_resume() noexcept {} private: @@ -46,7 +55,7 @@ namespace cppcoro friend class static_thread_pool; static_thread_pool* m_threadPool; - std::experimental::coroutine_handle<> m_awaitingCoroutine; + cppcoro_coroutine::coroutine_handle<> m_awaitingCoroutine; schedule_operation* m_next; }; diff --git a/include/cppcoro/task.hpp b/include/cppcoro/task.hpp index 3bff404f..852d5968 100644 --- a/include/cppcoro/task.hpp +++ b/include/cppcoro/task.hpp @@ -49,9 +49,7 @@ namespace cppcoro // were crashing under x86 optimised builds. template CPPCORO_NOINLINE - void await_suspend(std::experimental::coroutine_handle coroutine) - { - task_promise_base& promise = coroutine.promise(); + void await_suspend(std::experimental::coroutine_handle coroutine) noexcept // Use 'release' memory semantics in case we finish before the // awaiter can suspend so that the awaiting thread sees our diff --git a/lib/static_thread_pool.cpp b/lib/static_thread_pool.cpp index 36c39ce9..13847e1a 100644 --- a/lib/static_thread_pool.cpp +++ b/lib/static_thread_pool.cpp @@ -319,7 +319,7 @@ namespace cppcoro }; void static_thread_pool::schedule_operation::await_suspend( - std::experimental::coroutine_handle<> awaitingCoroutine) noexcept + cppcoro_coroutine::coroutine_handle<> awaitingCoroutine) noexcept { m_awaitingCoroutine = awaitingCoroutine; m_threadPool->schedule_impl(this);