emilib
Public Types | Public Member Functions | List of all members
emilib::ThreadPool Class Reference

Public Types

using Job = std::function< void()>
 

Public Member Functions

 ThreadPool ()
 As many threads as cores, but at least 2.
 
 ThreadPool (size_t num_threads)
 Use this many worker threads.
 
 ~ThreadPool ()
 Will block until all jobs have finished.
 
void wait ()
 Wait for all jobs to finish.
 
void clear ()
 Remove all jobs in the queue (but those that have already started will still finish).
 
void add_void (const Job &job)
 Add to queue and return immediately.
 
template<typename Result >
std::future< Result > add (std::function< Result()> job)
 Add to queue and return immediately.
 

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