XNetwork 1.7.5; VERSION ${PROJECT_VERSION}
Loading...
Searching...
No Matches
Classes | Namespaces
thread_pool.hpp File Reference
#include <condition_variable>
#include <functional>
#include <future>
#include <memory>
#include <mutex>
#include <queue>
#include <thread>
#include <type_traits>
#include <utility>
Include dependency graph for thread_pool.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  xnetwork::thread_pool
 

Namespaces

namespace  xnetwork
 

Detailed Description

Minimal header-only thread pool for C++17.

Owns a fixed set of worker threads that process tasks from a shared queue. Tasks are enqueued via enqueue() which returns a std::future to the result.

Usage:

auto future = pool.enqueue([] { return 42; });
int result = future.get();
Read-only map of maps of maps (view into a dict-of-dict-of-dict structure)
Definition coreviews.hpp:109
Definition thread_pool.hpp:35

The destructor waits for all pending tasks to finish and joins all worker threads. It is safe to destroy the pool while tasks are still running - remaining tasks are abandoned.