Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::ThreadPool Class Reference

#include <thread_pool.hpp>

Public Member Functions

 ThreadPool (size_t num_threads)
 
 ThreadPool (const ThreadPool &other)=delete
 
 ThreadPool (ThreadPool &&other)=delete
 
 ~ThreadPool ()
 
ThreadPooloperator= (const ThreadPool &other)=delete
 
ThreadPooloperator= (ThreadPool &&other)=delete
 
void enqueue (const std::function< void()> &task)
 
void wait ()
 
size_t num_threads ()
 

Private Member Functions

void worker_loop (size_t thread_index)
 

Private Attributes

std::vector< std::thread > workers
 
std::queue< std::function< void()> > tasks
 
std::mutex tasks_mutex
 
std::condition_variable condition
 
std::condition_variable finished_condition
 
std::atomic< size_t > tasks_running
 
bool stop = false
 

Detailed Description

Definition at line 13 of file thread_pool.hpp.

Constructor & Destructor Documentation

◆ ThreadPool() [1/3]

bb::ThreadPool::ThreadPool ( size_t  num_threads)

Definition at line 8 of file thread_pool.cpp.

◆ ThreadPool() [2/3]

bb::ThreadPool::ThreadPool ( const ThreadPool other)
delete

◆ ThreadPool() [3/3]

bb::ThreadPool::ThreadPool ( ThreadPool &&  other)
delete

◆ ~ThreadPool()

bb::ThreadPool::~ThreadPool ( )

Definition at line 16 of file thread_pool.cpp.

Member Function Documentation

◆ enqueue()

void bb::ThreadPool::enqueue ( const std::function< void()> &  task)

Definition at line 28 of file thread_pool.cpp.

◆ num_threads()

size_t bb::ThreadPool::num_threads ( )
inline

Definition at line 25 of file thread_pool.hpp.

◆ operator=() [1/2]

ThreadPool & bb::ThreadPool::operator= ( const ThreadPool other)
delete

◆ operator=() [2/2]

ThreadPool & bb::ThreadPool::operator= ( ThreadPool &&  other)
delete

◆ wait()

void bb::ThreadPool::wait ( )

Definition at line 37 of file thread_pool.cpp.

◆ worker_loop()

void bb::ThreadPool::worker_loop ( size_t  thread_index)
private

Definition at line 43 of file thread_pool.cpp.

Member Data Documentation

◆ condition

std::condition_variable bb::ThreadPool::condition
private

Definition at line 31 of file thread_pool.hpp.

◆ finished_condition

std::condition_variable bb::ThreadPool::finished_condition
private

Definition at line 32 of file thread_pool.hpp.

◆ stop

bool bb::ThreadPool::stop = false
private

Definition at line 34 of file thread_pool.hpp.

◆ tasks

std::queue<std::function<void()> > bb::ThreadPool::tasks
private

Definition at line 29 of file thread_pool.hpp.

◆ tasks_mutex

std::mutex bb::ThreadPool::tasks_mutex
private

Definition at line 30 of file thread_pool.hpp.

◆ tasks_running

std::atomic<size_t> bb::ThreadPool::tasks_running
private

Definition at line 33 of file thread_pool.hpp.

◆ workers

std::vector<std::thread> bb::ThreadPool::workers
private

Definition at line 28 of file thread_pool.hpp.


The documentation for this class was generated from the following files: