Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/ThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ThreadPool {
ThreadPool * m_pool;
public:
ThreadWorker(ThreadPool * pool, const int id)
: m_pool(pool), m_id(id) {
: m_id(id), m_pool(pool) {
}

void operator()() {
Expand All @@ -39,9 +39,9 @@ class ThreadPool {
}
};

std::vector<std::thread> m_threads;
bool m_shutdown;
SafeQueue<std::function<void()>> m_queue;
std::vector<std::thread> m_threads;
std::mutex m_conditional_mutex;
std::condition_variable m_conditional_lock;
public:
Expand All @@ -57,7 +57,7 @@ class ThreadPool {

// Inits thread pool
void init() {
for (int i = 0; i < m_threads.size(); ++i) {
for (size_t i = 0; i < m_threads.size(); ++i) {
m_threads[i] = std::thread(ThreadWorker(this, i));
}
}
Expand All @@ -67,7 +67,7 @@ class ThreadPool {
m_shutdown = true;
m_conditional_lock.notify_all();

for (int i = 0; i < m_threads.size(); ++i) {
for (size_t i = 0; i < m_threads.size(); ++i) {
if(m_threads[i].joinable()) {
m_threads[i].join();
}
Expand Down