Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions include/cppcoro/static_thread_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
#include <thread>
#include <vector>
#include <mutex>
#include <experimental/coroutine>

#if __has_include(<coroutine>)
#include <coroutine>
namespace cppcoro_coroutine = std;
#elif __has_include(<experimental/coroutine>)
#include <experimental/coroutine>
namespace cppcoro_coroutine = std::experimental;
#else
#error "No coroutine header available"
#endif

namespace cppcoro
{
Expand All @@ -38,15 +47,15 @@ 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:

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;

};
Expand Down
4 changes: 1 addition & 3 deletions include/cppcoro/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ namespace cppcoro
// were crashing under x86 optimised builds.
template<typename PROMISE>
CPPCORO_NOINLINE
void await_suspend(std::experimental::coroutine_handle<PROMISE> coroutine)
{
task_promise_base& promise = coroutine.promise();
void await_suspend(std::experimental::coroutine_handle<PROMISE> coroutine) noexcept

// Use 'release' memory semantics in case we finish before the
// awaiter can suspend so that the awaiting thread sees our
Expand Down
2 changes: 1 addition & 1 deletion lib/static_thread_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down