prevent starting of another scheduler if one is already running

master
Daniel Kolesa 2017-03-24 15:52:40 +01:00
parent f79236e94f
commit c1e0ae56ac
1 changed files with 4 additions and 0 deletions

View File

@ -11,6 +11,7 @@
#include <thread>
#include <utility>
#include <memory>
#include <stdexcept>
#include "ostd/platform.hh"
#include "ostd/coroutine.hh"
@ -58,6 +59,9 @@ namespace detail {
template<typename S>
current_scheduler_owner(S &sched) {
if (current_scheduler) {
throw std::logic_error{"another scheduler already running"};
}
current_scheduler = &sched;
}