-
Notifications
You must be signed in to change notification settings - Fork 4
Feature thread pool #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature thread pool #225
Conversation
src/dsm/headers/Dynamics.hpp
Outdated
| } | ||
| for (auto& thread : threads) { | ||
| thread.join(); | ||
| for (const auto& [itineraryId, pItinerary] : m_itineraries) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
src/dsm/headers/Dynamics.hpp
Outdated
| for (auto& thread : threads) { | ||
| thread.join(); | ||
| for (const auto& [itineraryId, pItinerary] : m_itineraries) { | ||
| m_pool.enqueue([this, &pItinerary] { this->m_updatePath(pItinerary); }); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| #include <stdexcept> | ||
|
|
||
| namespace dsm { | ||
| ThreadPool::ThreadPool(const unsigned int nThreads) : m_stop(false), m_nActiveTasks{0} { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| m_cv.wait(lock, [this]() { return m_stop || !m_tasks.empty(); }); | ||
|
|
||
| if (m_stop && m_tasks.empty()) { | ||
| return; |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 15.5 rule Note
| { | ||
| std::unique_lock<std::mutex> lock(m_mutex); | ||
| ++m_nActiveTasks; | ||
| m_tasks.emplace(std::move(task)); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 17.7 rule Note
|
|
||
| void ThreadPool::waitAll() { | ||
| std::unique_lock<std::mutex> lock(m_mutex); | ||
| m_cv.wait(lock, [this]() { return m_nActiveTasks == 0; }); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 15.5 rule Note
| std::condition_variable m_cv; | ||
|
|
||
| public: | ||
| ThreadPool(const unsigned int nThreads = std::thread::hardware_concurrency()); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 13.4 rule Note
| std::condition_variable m_cv; | ||
|
|
||
| public: | ||
| ThreadPool(const unsigned int nThreads = std::thread::hardware_concurrency()); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 17.8 rule Note
No description provided.