SpiecsEngine
 
Loading...
Searching...
No Matches

◆ Wait()

template<typename ... Params>
void Spices::ThreadPool_Basic< Params >::Wait ( )
inlineinherited

Wait for all tasks executed finish in taskqueue.

Definition at line 500 of file ThreadPoolBasic.h.

501 {
503
504 auto idleCond = [&]() {
505 return m_IdleThreadSize.load() == m_NThreads.load() && m_Tasks.load() == 0;
506 };
507
508 if (!idleCond())
509 {
510 std::unique_lock<std::mutex> lock(m_Mutex);
511 m_IdleCond.wait(lock, idleCond);
512 }
513
514 for (auto& pair : m_Threads)
515 {
516 pair.second->Wait();
517 }
518 }
#define SPICES_PROFILE_ZONE
std::atomic_int m_IdleThreadSize
Idled thread size.
std::atomic_int m_Tasks
Number of tasks;.
std::mutex m_Mutex
Mutex for thread safe.
std::unordered_map< uint32_t, std::unique_ptr< Thread< Params... > > > m_Threads
Threads Container.
std::atomic_int m_NThreads
Threads Count.
std::condition_variable m_IdleCond
Thread pool thread idle Condition.