QtCraft API C++ classes QML types Handbook

QcWorkerPool Class

Fixed set of worker threads executing queued jobs in FIFO order. More...

Header: #include <common/core/QcWorkerPool.h>

Public Functions

QcWorkerPool(const QcWorkerPool &)
qsizetype discardQueued()
void submit(std::function<void ()> job)
void submitFirst(std::function<void ()> job)
int threadCount() const
void waitForIdle()
QcWorkerPool &operator=(const QcWorkerPool &)

Detailed Description

Jobs are handed over through std::mutex/std::condition_variable so ThreadSanitizer can follow the data (see QcMailbox).

Member Function Documentation

[delete] QcWorkerPool::QcWorkerPool(const QcWorkerPool &)

Copy-constructs an instance of QcWorkerPool. This function is deleted.

qsizetype QcWorkerPool::discardQueued()

Drops the jobs that have not started yet and returns how many; running jobs go on.

void QcWorkerPool::submit(std::function<void ()> job)

Puts job at the end of the queue.

void QcWorkerPool::submitFirst(std::function<void ()> job)

Puts job before every job that has not started yet.

int QcWorkerPool::threadCount() const

Returns the number of worker threads.

void QcWorkerPool::waitForIdle()

Blocks until the queue is empty and no job is running.

[delete] QcWorkerPool &QcWorkerPool::operator=(const QcWorkerPool &)

Copy-assigns other to this QcWorkerPool instance. This function is deleted.