You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/llarp/threadpool.hpp

34 lines
637 B
C++

#ifndef LLARP_THREADPOOL_HPP
#define LLARP_THREADPOOL_HPP
#include <llarp/threadpool.h>
#include <condition_variable>
#include <deque>
6 years ago
#include <mutex>
7 years ago
#include <thread>
#include <vector>
7 years ago
namespace llarp {
namespace thread {
typedef std::mutex mtx_t;
typedef std::unique_lock<mtx_t> lock_t;
struct Pool {
Pool(size_t sz);
6 years ago
void QueueJob(const llarp_thread_job& job);
7 years ago
void Join();
void Stop();
7 years ago
std::vector<std::thread> threads;
std::deque<llarp_thread_job> jobs;
7 years ago
mtx_t queue_mutex;
std::condition_variable condition;
std::condition_variable done;
6 years ago
bool stop;
7 years ago
};
6 years ago
} // namespace thread
} // namespace llarp
#endif