JobSystem.ixx File
Thread-pool-based job scheduler with blocking wait semantics. More...
Included Headers
#include <condition_variable>
#include <thread>
#include <cstddef>
#include <queue>
#include <vector>
#include <functional>
Namespaces Index
| namespace | helios |
| namespace | engine |
| namespace | core |
| namespace | thread |
Classes Index
| class | JobSystem |
|
A fixed-size thread pool for parallel job execution. More... | |
Description
Thread-pool-based job scheduler with blocking wait semantics.
File Listing
The file content with the documentation metadata removed is:
17export namespace helios::engine::core::thread {
40 std::queue<std::function<void()>> jobQueue_;
61 explicit JobSystem(const std::size_t maxWorkerCount) : maxWorkerCount_(maxWorkerCount) {
63 workerThreads_.reserve(maxWorkerCount);
65 for (std::size_t i = 0; i < maxWorkerCount; ++i) {
66 workerThreads_.emplace_back([this](std::stop_token stopToken) {
67 while (!stopToken.stop_requested()) {
83 job();
103 void runAndWait(std::size_t jobCount, Fn&& fn) {
107 pendingJobCount_ = jobCount;
115 std::lock_guard lok(mutex_);
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.