#pragma once #include "PriorityQueue.h" #include "Task.h" #include #include #include #include #include #include #include class Thread; using QueueType = PriorityQueue; class ThreadPool : public QObject { public: ThreadPool(size_t threads_num = QThread::idealThreadCount(), QObject *parent = nullptr); ~ThreadPool(); void enqueue(Task& t); void start(); int tasksCount(); private: QVector> m_threads; bool is_running = false; QueueType m_tasks; QMutex m_mutex; QWaitCondition m_cond; friend class Thread; };