SpiecsEngine
 
Loading...
Searching...
No Matches
Spices::VulkanCmdThreadPool Class Reference

Wrappers of RHI Thread Pool. More...

#include <VulkanCmdThreadPool.h>

Inheritance diagram for Spices::VulkanCmdThreadPool:
Spices::VulkanObject Spices::ThreadPool_Basic< VkCommandBuffer >

Public Types

using Task
 Thread Function lambda Object.
 

Public Member Functions

 VulkanCmdThreadPool (VulkanState &vulkanState, const std::string &name)
 Constructor Function. Create Specific ThreadPool.
 
virtual ~VulkanCmdThreadPool () override
 Destructor Function.
 
void Start (int initThreadSize=0.5 *std::thread::hardware_concurrency())
 Start Run this thread pool.
 
template<typename Func , typename ... Args>
auto SubmitPoolTask (Func &&func, Args &&...args) -> std::future< decltype(func(nullptr, std::forward< Args >(args)...))>
 Submit a part commands task to task queue, and wait for a idle thread to execute it.
 
void ThreadFunc (Thread< VkCommandBuffer > *thread)
 Thread Function.
 
VkCommandBuffer CreateParallelCommandBuffers (uint32_t threadId)
 Create second CommandBuffer in rhi threadPool thread.
 
void FreeParallelCommandBuffers (uint32_t frameIndex)
 Free all second CommandBuffer in rhi threadPool thread.
 
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.
 
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 PoolModeGetPoolMode () 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

VulkanStatem_VulkanState
 The global VulkanState Referenced from VulkanRenderBackend.
 
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< Taskm_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.
 

Private Attributes

std::vector< VkCommandPool > m_CmdPools
 Parallel CommandPools.
 
std::array< std::vector< std::vector< VkCommandBuffer > >, MaxFrameInFlightm_CmdBuffers
 Parallel Secondary CommandBuffers.
 

Detailed Description

Wrappers of RHI Thread Pool.

Definition at line 20 of file VulkanCmdThreadPool.h.


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