Commit 234e5684 authored by Xavier Thompson's avatar Xavier Thompson

Refactor Scheduler::suspend

parent 2037fb43
......@@ -57,12 +57,10 @@ namespace typon
return result;
}
static Deque * suspend(std::coroutine_handle<> coroutine) noexcept
static auto suspend(std::coroutine_handle<> coroutine) noexcept
{
Worker & worker = get()._worker[thread_id];
Deque * deque = worker._deque.load();
worker._deque.store(nullptr);
deque->suspend(coroutine);
auto deque = worker.suspend(coroutine);
uint id = fdt::random::random() % get()._concurrency;
get()._worker[id].add(deque);
return deque;
......
......@@ -2,6 +2,7 @@
#define TYPON_CORE_WORKER_HPP_INCLUDED
#include <atomic>
#include <coroutine>
#include <mutex>
#include <type_traits>
#include <utility>
......@@ -60,6 +61,14 @@ namespace typon
}
}
auto suspend(std::coroutine_handle<> coroutine) noexcept
{
auto deque = _deque.load();
_deque.store(nullptr);
deque->suspend(coroutine);
return deque;
}
void resume(Work & work) noexcept
{
auto deque = _deque.load();
......
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