Commit e64a5f8b authored by Xavier Thompson's avatar Xavier Thompson

scheduler.hpp: Use multiple calls to Scheduler::get()

parent 2ba25c7b
......@@ -36,10 +36,9 @@ namespace typon
static void schedule(std::coroutine_handle<> task) noexcept
{
Scheduler & scheduler = get();
uint id = fdt::random::random() % scheduler._concurrency;
scheduler._worker[id].add(new Deque(task));
scheduler._notifyer.notify_one();
uint id = fdt::random::random() % get()._concurrency;
get()._worker[id].add(new Deque(task));
get()._notifyer.notify_one();
}
static void push(Continuation task) noexcept
......@@ -49,25 +48,23 @@ namespace typon
static bool pop() noexcept
{
Scheduler & scheduler = get();
Deque * deque = scheduler._worker[thread_id]._deque.load();
Deque * deque = get()._worker[thread_id]._deque.load();
bool result = deque->pop();
if (auto garbage = deque->reclaim())
{
scheduler._gc.retire(garbage);
get()._gc.retire(garbage);
}
return result;
}
static Deque * suspend(std::coroutine_handle<> coroutine) noexcept
{
Scheduler & scheduler = get();
Worker & worker = scheduler._worker[thread_id];
Worker & worker = get()._worker[thread_id];
Deque * deque = worker._deque.load();
worker._deque.store(nullptr);
deque->suspend(coroutine);
uint id = fdt::random::random() % scheduler._concurrency;
scheduler._worker[id].add(deque);
uint id = fdt::random::random() % get()._concurrency;
get()._worker[id].add(deque);
return deque;
}
......@@ -76,9 +73,8 @@ namespace typon
auto state = deque->_state.exchange(Deque::Resumable);
if (state == Deque::Empty)
{
Scheduler & scheduler = get();
uint id = fdt::random::random() % scheduler._concurrency;
scheduler._worker[id].add(deque);
uint id = fdt::random::random() % get()._concurrency;
get()._worker[id].add(deque);
}
get()._notifyer.notify_one();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment