Class sh::base::ThreadPool

class sh::base::ThreadPool : public QObject

A pool of worker threads doing some short jobs from a queue.

Public Static Functions

void enqueueForce(std::function<void()> fct)

Enqueues code to the threadpool.

void enqueueForce(std::function<void()> fctstd::shared_ptr<void> obj1, std::shared_ptr<void> obj2 = 0, std::shared_ptr<void> obj3 = 0, )

Enqueues code to the threadpool.

It can also conserve some shared pointers until after execution.

void enqueueForceBeyondAsyncCallBarrier(std::function<void()> fctstd::shared_ptr<void> obj1 = 0, std::shared_ptr<void> obj2 = 0, std::shared_ptr<void> obj3 = 0, )

Enqueues code to the threadpool and forbids async calls within it. This is useful for ensuring that no code might access a certain object after its deletion.

It can also conserve some shared pointers until after execution.

void enqueueIfIn(std::function<void()> fctQThread *thread, )

Enqueues code to the threadpool if currently in thread. Otherwise executes directly.

void enqueueIfInMain(std::function<void()> fct)

Enqueues code to the threadpool if currently in main thread. Otherwise executes directly.

void doShutdown()

Only called by the Shallot infrastructure for shutdown.

bool isShuttingDown()
bool isShutdown()
int getThreadCount()
void respectThreadAbort()
void doInitialize()

Private Static Functions

void _enqueueForce(std::function<void()> fct)

Private Static Attributes

const int THREAD_COUNT = 10
QMutex poolmutex
QWaitCondition pooladdedcondition
QList<std::function<void()>> tasks
bool _shutsdown = false
QList<ThreadPoolThread*> _threads
int _threadsalive = 0

Friends

friend class ThreadPoolThread