Skip to content

middzwb/ThreadPool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ThreadPool

GitHub Workflow Status

simple c++17 thread pool

Usage:

    // initialize thread pool
    ThreadPool tp(8);
    using namespace std;

    auto fu = tp.enqueue([](int a, int b) ->int { return a + b; }, 123, 456);
    assert(fu.get() == 579);

    for (int i = 0; i < 8; ++i) {
        tp.enqueue([]() { this_thread::sleep_for(1s); });
    }
    // wait for all task finished.
    tp.drain();
    // stop thread pool
    tp.stop();

About

simple thread pool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages