make channels outside of scheduler
parent
47145f0431
commit
d73ad08e87
|
@ -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) {
|
||||||
|
|
|
@ -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 */
|
||||||
|
|
Loading…
Reference in New Issue