[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/dominiksmolinski3/Simple-Thread-Pool/main/SimpleThreadPool.cpp [Back]  [Original]

#include "SimpleThreadPool.h"
#include 
SimpleThreadPool::SimpleThreadPool(std::size_t threadCount)
    : m_threadCount(threadCount), stop(false) {
    for (size_t i = 0; i < m_threadCount; ++i) {
        threads.emplace_back([this] {
            while (true) {
                std::function task;
                {
                    std::unique_lock lock(mut);
                    condition.wait(lock, [this] { return stop || !tasks.empty(); });
                    if (stop && tasks.empty()) return;
                    task = std::move(tasks.front());
                    tasks.pop();
                }
                task();
            }
        });
    }

    std::cout 

Web Proxy Viewer  |  New URL  |  Original Page