adamdebreceni commented on code in PR #1458:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1458#discussion_r1062425264
##########
libminifi/include/utils/ThreadPool.h:
##########
@@ -296,6 +297,9 @@ class ThreadPool {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
+
+ static std::shared_ptr<core::logging::Logger> logger_;
Review Comment:
moved it into the object
##########
libminifi/src/utils/ThreadPool.cpp:
##########
@@ -182,15 +185,22 @@ void ThreadPool<T>::manageWorkers() {
template<typename T>
void ThreadPool<T>::start() {
- if (nullptr != controller_service_provider_) {
- auto thread_man =
controller_service_provider_->getControllerService("ThreadPoolManager");
- thread_manager_ = thread_man != nullptr ?
std::dynamic_pointer_cast<controllers::ThreadManagementService>(thread_man) :
nullptr;
- } else {
- thread_manager_ = nullptr;
- }
-
std::lock_guard<std::recursive_mutex> lock(manager_mutex_);
if (!running_) {
+ thread_manager_.reset();
+ if (nullptr != controller_service_provider_) {
+ auto service =
controller_service_provider_->getControllerService("ThreadPoolManager");
+ if (!service) {
+ logger_->log_info("Could not find a ThreadPoolManager service");
+ } else {
+ if (auto thread_manager_service =
std::dynamic_pointer_cast<controllers::ThreadManagementService>(service)) {
+ thread_manager_ = thread_manager_service;
+ } else {
+ logger_->log_error("Found ThreadPoolManager, but it is not a
ThreadManagementService");
+ }
+ }
+ }
Review Comment:
good idea, changed it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]