libgrape-lite
A C++ library for parallel graph processing
|
#include <thread_pool.h>
Public Member Functions | |
ThreadPool (ThreadPool const &)=delete | |
ThreadPool & | operator= (ThreadPool const &)=delete |
void | InitThreadPool (const grape::ParallelEngineSpec &) |
template<class F , class... Args> | |
auto | enqueue (F &&f, Args &&... args) -> std::future< grape::result_of_t< F, Args... >> |
int | GetThreadNum () |
void | WaitEnd (std::vector< std::future< void >> &results) |
Private Attributes | |
std::vector< std::thread > | workers |
std::queue< std::function< void()> > | tasks |
std::mutex | queue_mutex |
std::condition_variable | condition |
bool | stop {false} |
size_t | thread_num_ {1} |
Credits to Jakob Progsch (@progschj) https://github.com/progschj/ThreadPool
Copyright (c) 2012 Jakob Progsch, Václav Zeman
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
Modified by Binrui Li at Alibaba Group, 2021.