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>
impl(F &func): p_lock(), p_cond(func) {}
impl(F &func): p_lock(), p_cond(func()) {}
template<typename U>
void put(U &&val) {

View File

@ -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<typename T>
channel<T> make_channel() {
return channel<T>{};
generic_condvar make_condition() {
return generic_condvar{};
}
private:
@ -221,9 +221,8 @@ public:
ctx->yield();
}
template<typename T>
channel<T> make_channel() {
return channel<T>{[this]() {
generic_condvar make_condition() {
return generic_condvar{[this]() {
return coro_cond{*this};
}};
}
@ -399,9 +398,8 @@ public:
task::current()->yield();
}
template<typename T>
channel<T> make_channel() {
return channel<T>{[this]() {
generic_condvar make_condition() {
return generic_condvar{[this]() {
return task_cond{*this};
}};
}
@ -543,7 +541,9 @@ inline void yield(S &sched) {
template<typename T, typename S>
inline channel<T> make_channel(S &sched) {
return sched.template make_channel<T>();
return channel<T>{[&sched]() {
return sched.make_condition();
}};
}
} /* namespace ostd */