Add threadpool::invalidate function
This commit is contained in:
parent
5d20755a66
commit
03e81c0457
@ -39,6 +39,8 @@ namespace rexy{
|
||||
threadpool& operator=(const threadpool&) = delete;
|
||||
threadpool& operator=(threadpool&&) = delete;
|
||||
|
||||
void invalidate(void);
|
||||
|
||||
template<class Func, class... Args>
|
||||
auto add_job(Func&& f, Args&&... args) -> std::future<decltype(std::forward<Func>(f)(std::forward<Args>(args)...))>;
|
||||
|
||||
|
||||
@ -48,12 +48,16 @@ namespace rexy{
|
||||
m_ctor_lock.unlock();
|
||||
}
|
||||
threadpool::~threadpool(void){
|
||||
m_valid = false;
|
||||
//wakeup all workers and end them
|
||||
m_qcv.notify_all();
|
||||
invalidate();
|
||||
for(auto& thread : m_workers){
|
||||
thread.join();
|
||||
}
|
||||
}
|
||||
|
||||
void threadpool::invalidate(void){
|
||||
m_valid = false;
|
||||
//wakeup all workers and end them
|
||||
m_qcv.notify_all();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user