Castor3D 0.16.0
Multiplatform 3D engine
Public Member Functions | List of all members
castor::ThreadPool Class Reference

#include <ThreadPool.hpp>

Inheritance diagram for castor::ThreadPool:
Inheritance graph
[legend]
Collaboration diagram for castor::ThreadPool:
Collaboration graph
[legend]

Public Member Functions

CU_API ThreadPool (size_t count)
 Constructor, initialises the pool with given threads count.
 
CU_API ~ThreadPool () noexcept
 Destructor.
 
CU_API bool isEmpty () const
 
CU_API bool isFull () const
 
CU_API bool waitAll (Milliseconds const &timeout) const
 Waits for all the threads to finish their job.
 
CU_API void pushJob (WorkerThread::Job job)
 Feeds a worker thread with the given job.
 
size_t getCount () const noexcept
 

Additional Inherited Members

- Protected Member Functions inherited from castor::NonMovable
 NonMovable ()=default
 Constructor.
 
 ~NonMovable () noexcept=default
 Destructor.
 

Constructor & Destructor Documentation

◆ ThreadPool()

CU_API castor::ThreadPool::ThreadPool ( size_t count)
explicit

Constructor, initialises the pool with given threads count.

Parameters
[in]countThe threads count.

◆ ~ThreadPool()

CU_API castor::ThreadPool::~ThreadPool ( )
noexcept

Destructor.

Member Function Documentation

◆ getCount()

size_t castor::ThreadPool::getCount ( ) const
inlinenoexcept
Returns
The threads count.

◆ isEmpty()

CU_API bool castor::ThreadPool::isEmpty ( ) const
Returns
true if all the threads are busy.

◆ isFull()

CU_API bool castor::ThreadPool::isFull ( ) const
Returns
true if all the threads are idle.

◆ pushJob()

CU_API void castor::ThreadPool::pushJob ( WorkerThread::Job job)

Feeds a worker thread with the given job.

Remarks
If no thread is available, waits for one to finish its job.
Parameters
[in]jobThe job.

◆ waitAll()

CU_API bool castor::ThreadPool::waitAll ( Milliseconds const & timeout) const

Waits for all the threads to finish their job.

Parameters
[in]timeoutThe maximum time to wait.
Returns
true if all threads have finished.

The documentation for this class was generated from the following file: