Thread Pool Basic Class. Instance inherited from it and use multithreading feature. More...
#include <ThreadPoolBasic.h>
Public Types | |
| using | Task = std::function<void(Params...)> |
| Thread Function lambda Object. | |
Public Member Functions | |
| ThreadPool_Basic (const std::string &name="NonNameT") | |
| Constructor Function. | |
| virtual | ~ThreadPool_Basic () |
| Destructor Function. | |
| ThreadPool_Basic (const ThreadPool_Basic &)=delete | |
| Copy Constructor Function. | |
| ThreadPool_Basic & | operator= (const ThreadPool_Basic &)=delete |
| Copy Assignment Operation. | |
| void | SetMode (PoolMode mode) |
| Set Pool Run Mode. | |
| void | SetThreadIdleTimeOut (int idleTime) |
| Set Pool Threads idle time out. | |
| void | Wait () |
| Wait for all tasks executed finish in taskqueue. | |
| void | Continue () |
| Continue ThreadPool. | |
| void | Suspend () |
| Suspend ThreadPool. | |
| void | SubmitThreadTask_LightWeight (uint32_t threadId, std::function< void(Params...)> func) |
| Submit a task to specific thread. | |
| void | SubmitThreadTask_LightWeight_ForEach (std::function< void(Params...)> func) |
| Submit a task to all thread. | |
| void | ThreadFunc (Thread<> *thread) |
| Thread Function. | |
| template<typename Func , typename... Args> | |
| auto | SubmitPoolTask (Func &&func, Args &&... args) -> std::future< decltype(func(std::forward< Args >(args)...))> |
| Submit a task to task queue, and wait for a idle thread to execute it. | |
| void | Start (int initThreadSize=0.5 *std::thread::hardware_concurrency()) |
| Start Run this thread pool. | |
| const int | GetThreadsCount () const |
| Get Threads Count. This function is just used for unit test, should not be used in engine. | |
| const std::unordered_map< uint32_t, std::unique_ptr< Thread< Params... > > > & | GetThreads () const |
| Get Threads. This function is just used for unit test, should not be used in engine. | |
| const int | GetInitThreadSize () const |
| GetInitThreadSize. This function is just used for unit test, should not be used in engine. | |
| const int | GetIdleThreadSize () const |
| GetIdleThreadSize. This function is just used for unit test, should not be used in engine. | |
| const int | GetTasks () const |
| Get TaskQueue Count. This function is just used for unit test, should not be used in engine. | |
| const PoolMode & | GetPoolMode () const |
| GetPoolMode. This function is just used for unit test, should not be used in engine. | |
| const int | GetThreadIdleTimeOut () const |
| ThreadIdleTimeOut. This function is just used for unit test, should not be used in engine. | |
| const bool | IsPoolRunning () const |
| GetIsPoolRunning. This function is just used for unit test, should not be used in engine. | |
Protected Member Functions | |
| bool | CheckRunningState () const |
| Check whether this pool is still in running. | |
Protected Attributes | |
| std::string | m_PoolName |
| This ThreadPool Name. | |
| std::unordered_map< uint32_t, std::unique_ptr< Thread< Params... > > > | m_Threads |
| Threads Container. | |
| std::atomic_int | m_NThreads |
| Threads Count. | |
| uint32_t | m_InitThreadSize |
| Initialized thread size. | |
| uint32_t | m_ThreadIdleTimeOut |
| thread idle time out. | |
| std::atomic_int | m_IdleThreadSize |
| Idled thread size. | |
| std::queue< Task > | m_TaskQueue |
| Task Queue. | |
| std::atomic_int | m_Tasks |
| Number of tasks;. | |
| std::mutex | m_Mutex |
| Mutex for thread safe. | |
| std::condition_variable | m_NotEmpty |
| Task Queue not empty. | |
| std::condition_variable | m_ExitCond |
| Thread pool Exit Condition. | |
| std::condition_variable | m_IdleCond |
| Thread pool thread idle Condition. | |
| PoolMode | m_PoolMode |
| Thread Pool Run Mode. | |
| std::atomic_bool | m_IsPoolRunning |
| True if this thread pool is in use. | |
| bool | m_IsSuspend |
| True if needs suspend on executing the task. | |
Thread Pool Basic Class. Instance inherited from it and use multithreading feature.
Definition at line 160 of file ThreadPoolBasic.h.