diff --git a/ostd/channel.hh b/ostd/channel.hh index 1e1108b..e196b88 100644 --- a/ostd/channel.hh +++ b/ostd/channel.hh @@ -73,7 +73,7 @@ private: } template - impl(F &func): p_lock(), p_cond(func) {} + impl(F &func): p_lock(), p_cond(func()) {} template void put(U &&val) { diff --git a/ostd/concurrency.hh b/ostd/concurrency.hh index 5319eba..02ebb33 100644 --- a/ostd/concurrency.hh +++ b/ostd/concurrency.hh @@ -15,6 +15,7 @@ #include "ostd/platform.hh" #include "ostd/coroutine.hh" #include "ostd/channel.hh" +#include "ostd/generic_condvar.hh" namespace ostd { @@ -46,9 +47,8 @@ struct thread_scheduler { std::this_thread::yield(); } - template - channel make_channel() { - return channel{}; + generic_condvar make_condition() { + return generic_condvar{}; } private: @@ -221,9 +221,8 @@ public: ctx->yield(); } - template - channel make_channel() { - return channel{[this]() { + generic_condvar make_condition() { + return generic_condvar{[this]() { return coro_cond{*this}; }}; } @@ -399,9 +398,8 @@ public: task::current()->yield(); } - template - channel make_channel() { - return channel{[this]() { + generic_condvar make_condition() { + return generic_condvar{[this]() { return task_cond{*this}; }}; } @@ -543,7 +541,9 @@ inline void yield(S &sched) { template inline channel make_channel(S &sched) { - return sched.template make_channel(); + return channel{[&sched]() { + return sched.make_condition(); + }}; } } /* namespace ostd */