1 #ifndef TPZTHREADPOOL_H 2 #define TPZTHREADPOOL_H 15 #include <condition_variable> 37 template<
typename... Args>
38 std::shared_future<void>
run(
const int priority,
TPZTaskGroup *taskGroup, std::function<
void(Args...) > func, Args... args) {
41 return run(priority, task, taskGroup);
44 template<
typename... Args>
73 template<
typename... Args>
74 std::shared_future<void>
runSystemTask(
const int priority, std::function<
void(Args...) > func, Args... args) {
77 std::shared_future<void> fut = task->get_future().share();
96 #endif // TPZTHREADPOOL_H
pthread_mutex_t mutex
Semaphore which controls multiple threads.
TPZAutoPointer< TPZReschedulableTask > runReschedulable(const int priority, TPZTaskGroup *taskGroup, std::function< void(Args...) > func, Args... args)
unsigned int mThreadsToDelete
int ActualThreadCount() const
std::condition_variable mTaskAvailableCond
Administers tasks that will be executed asynchronously.
std::mutex mThreadsMutex
one mutex to synchronize access to the data structures
std::shared_future< void > runSystemTask(const int priority, std::function< void(Args...) > func, Args... args)
Submits and processes a "maximum priority" system task.
void appendTaskToQueue(TPZAutoPointer< TPZTask > &task)
static TPZThreadPool & globalInstance()
TPZPriorityQueue< TPZAutoPointer< TPZTask >, std::vector< TPZAutoPointer< TPZTask > >, TPZTaskOrdering > mTasksQueue
void reschedule(const int priority, TPZAutoPointer< TPZReschedulableTask > &task)
std::shared_future< void > run(const int priority, TPZAutoPointer< std::packaged_task< void(void) > > &task, TPZTaskGroup *taskGroup=NULL)
submits a task to be executed by TPZThreadPool
void checkForMaxAndMinPriority(const int priority)
Contains declaration of the TPZAutoPointer class which has Increment and Decrement actions are mutexe...
unsigned int mZombieThreads
void SetNumThreads(const unsigned numThreads)
sets the number of threads to be executed simultaneously
Simple struct needed by std::priority_queue for ordering the items.
std::shared_future< void > run(const int priority, TPZTaskGroup *taskGroup, std::function< void(Args...) > func, Args... args)
std::vector< std::thread > mThreads
vector of thread objects
std::shared_future< void > runNow(TPZAutoPointer< TPZReschedulableTask > &task)
This class implements a reference counter mechanism to administer a dynamically allocated object...