make channels outside of scheduler

master
Daniel Kolesa 2017-03-23 10:41:13 +01:00
parent 47145f0431
commit d73ad08e87
2 changed files with 11 additions and 11 deletions

View File

@ -73,7 +73,7 @@ private:
} }
template<typename F> template<typename F>
impl(F &func): p_lock(), p_cond(func) {} impl(F &func): p_lock(), p_cond(func()) {}
template<typename U> template<typename U>
void put(U &&val) { void put(U &&val) {

View File

@ -15,6 +15,7 @@
#include "ostd/platform.hh" #include "ostd/platform.hh"
#include "ostd/coroutine.hh" #include "ostd/coroutine.hh"
#include "ostd/channel.hh" #include "ostd/channel.hh"
#include "ostd/generic_condvar.hh"
namespace ostd { namespace ostd {
@ -46,9 +47,8 @@ struct thread_scheduler {
std::this_thread::yield(); std::this_thread::yield();
} }
template<typename T> generic_condvar make_condition() {
channel<T> make_channel() { return generic_condvar{};
return channel<T>{};
} }
private: private:
@ -221,9 +221,8 @@ public:
ctx->yield(); ctx->yield();
} }
template<typename T> generic_condvar make_condition() {
channel<T> make_channel() { return generic_condvar{[this]() {
return channel<T>{[this]() {
return coro_cond{*this}; return coro_cond{*this};
}}; }};
} }
@ -399,9 +398,8 @@ public:
task::current()->yield(); task::current()->yield();
} }
template<typename T> generic_condvar make_condition() {
channel<T> make_channel() { return generic_condvar{[this]() {
return channel<T>{[this]() {
return task_cond{*this}; return task_cond{*this};
}}; }};
} }
@ -543,7 +541,9 @@ inline void yield(S &sched) {
template<typename T, typename S> template<typename T, typename S>
inline channel<T> make_channel(S &sched) { inline channel<T> make_channel(S &sched) {
return sched.template make_channel<T>(); return channel<T>{[&sched]() {
return sched.make_condition();
}};
} }
} /* namespace ostd */ } /* namespace ostd */