Skip to content

A simple C++11 Thread Pool implementation

License

Notifications You must be signed in to change notification settings

caock/ThreadPool

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ThreadPool

A simple C++11 Thread Pool implementation.

Basic usage:

// create thread pool with 4 worker threads
ThreadPool pool(4);

// enqueue and store future
auto result = pool.enqueue([](int answer) { return answer; }, 42);

// get result from future
std::cout << result.get() << std::endl;

advanced usage (bind thread to specific cpu core):

// create thread pool with 4 worker threads
ThreadPool pool(4);
int bind_core_id = 0;

// enqueue and store future
auto result = pool.strict_enqueue(bind_core_id, [](int answer) { return answer; }, 42);

// get result from future
std::cout << result.get() << std::endl;

more powerful examples in example.cpp file.

About

A simple C++11 Thread Pool implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 78.3%
  • C 18.6%
  • CMake 3.1%