Commit b3fb4d4f authored by Xavier Thompson's avatar Xavier Thompson

Give every worker a reference to the scheduler's gc

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