Skip to content

Commit bb393fe

Browse files
committed
fulfill rule-of-5
Deleted copy&move ctors&assignments because of limitations by attributes (sync objects have nothing of both). Set dtor virtual for polymorphism - ThreadPool has attributes which need to get their dtors called too and running threads shouldn't get lost.
1 parent 6ba7e87 commit bb393fe

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ThreadPool.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class ThreadPool {
4444
}
4545
);
4646
}
47+
ThreadPool(const ThreadPool&) = delete;
48+
ThreadPool& operator=(const ThreadPool&) = delete;
49+
ThreadPool(ThreadPool&&) = delete;
50+
ThreadPool& operator=(ThreadPool&&) = delete;
4751
// add new work item to the pool
4852
template<class F, class... Args>
4953
std::future<typename std::result_of<F(Args...)>::type> enqueue(F&& f, Args&&... args)
@@ -62,7 +66,7 @@ class ThreadPool {
6266
return res;
6367
}
6468
// the destructor joins all threads
65-
~ThreadPool()
69+
virtual ~ThreadPool()
6670
{
6771
this->stop = true;
6872
this->condition.notify_all();

0 commit comments

Comments
 (0)