Commit cb264baa authored by Xavier Thompson's avatar Xavier Thompson

Give every worker a reference to the scheduler's gc

parent 49bb603e
......@@ -98,6 +98,11 @@ namespace typon
, _concurrency(concurrency)
, _gc(concurrency)
{
for (uint i = 0; i < concurrency; i++)
{
_worker[i]._gc = &_gc;
}
thread_id = concurrency;
for (uint id = 0; id < concurrency; id++)
......@@ -137,11 +142,7 @@ namespace typon
_notifyer.notify_one();
}
}
auto garbage = _worker[thread_id].resume(work);
if (garbage)
{
_gc.retire(garbage);
}
_worker[thread_id].resume(work);
_actives.fetch_sub(1);
}
......
......@@ -45,6 +45,7 @@ namespace typon
std::mutex _mutex;
std::atomic<Deque *> _active {nullptr};
std::vector<Deque *> _pool;
fdt::lock_free::garbage_collector * _gc;
~Worker()
{
......@@ -58,17 +59,17 @@ namespace typon
}
}
Deque * resume(Work & work) noexcept
void resume(Work & work) noexcept
{
auto active = _active.load();
if (work._state == Work::Resumable)
{
_active.store(work._deque);
work._deque->resume();
if (active)
{
return active;
_gc->retire(active);
}
work._deque->resume();
}
else
{
......@@ -78,7 +79,6 @@ namespace typon
}
work._task.resume();
}
return nullptr;
}
void add(Deque * deque) noexcept
......
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