mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 04:21:51 +00:00
thread pool: add function to detach threads
This commit is contained in:
1 parent
386943de39
commit
f2cee8e9ce
2 files changed
+12
-1
No files matched your search
+11
-1
@@ -85,7 +85,7 @@ ThreadPool::run(std::function<void()>&& cb)
|
||||
auto waitCond = [&](){ return not running_ or not tasks_.empty(); };
|
||||
if (permanent_thread)
|
||||
cv_.wait(l, waitCond);
|
||||
else
|
||||
else
|
||||
cv_.wait_for(l, e, waitCond);
|
||||
readyThreads_--;
|
||||
if (not running_ or tasks_.empty())
|
||||
@@ -166,6 +166,16 @@ ThreadPool::join()
|
||||
tasks_ = {};
|
||||
}
|
||||
|
||||
void
|
||||
ThreadPool::detach()
|
||||
{
|
||||
stop(false);
|
||||
for (auto& t : threads_)
|
||||
t->detach();
|
||||
threads_.clear();
|
||||
tasks_ = {};
|
||||
}
|
||||
|
||||
void
|
||||
Executor::run(std::function<void()>&& task)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user