SpiecsEngine
 
Loading...
Searching...
No Matches
Spices::Thread< Params > Class Template Reference

Thread Function Object. More...

#include <ThreadPoolBasic.h>

Public Types

using ThreadTask = std::function<void(Params...)>
 Thread Task.
 
using ThreadFunc = std::function<void(Thread*)>
 Thread Function.
 

Public Member Functions

 Thread (ThreadFunc func, uint32_t threadId)
 Constructor Function.
 
virtual ~Thread ()=default
 Destructor Function.
 
 Thread (const Thread &)=delete
 Copy Constructor Function.
 
Threadoperator= (const Thread &)=delete
 Copy Assignment Operation.
 
void Start ()
 Start a thread to execute Thread Function.
 
uint32_t GetId () const
 Get Thread Id.
 
void ReceiveThreadTask (std::function< void(Params...)> func)
 Receive a task must execute by this thread.
 
auto RequireTask () -> ThreadTask
 Get this mutex.
 
void Wait () const
 Wait for all thread tasks finished.
 
void SetThreadInTask (bool isInTask)
 Set this Thread is in task or not.
 
bool GetThreadInTask () const
 Get this Thread is in task or not.
 
int GetThreadTasksCount () const
 Get Thread Tasks Count. @reutrn Returns the Thread Tasks Count.
 

Private Attributes

std::mutex m_Mutex
 A Mutex for Thread.
 
ThreadFunc m_Func
 Thread Function.
 
uint32_t m_ThreadId
 Thread Id.
 
std::queue< ThreadTaskm_ThreadTasksQueue
 Thread Tasks Queue.
 
std::atomic_int m_ThreadTasks
 Thread Tasks Count.
 
std::atomic_bool m_IsInTask
 True if this thread is executing a task.
 

Detailed Description

template<typename ... Params>
class Spices::Thread< Params >

Thread Function Object.

Definition at line 23 of file ThreadPoolBasic.h.


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