dam4rus commented on a change in pull request #1022:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1022#discussion_r589324834



##########
File path: extensions/standard-processors/processors/GetTCP.cpp
##########
@@ -285,21 +285,17 @@ void GetTCP::onTrigger(const 
std::shared_ptr<core::ProcessContext> &context, con
       } else {
         logger_->log_error("Could not create socket for %s", endpoint);
       }
-      auto* future = new std::future<int>();
       std::unique_ptr<utils::AfterExecute<int>> after_execute = 
std::unique_ptr<utils::AfterExecute<int>>(new SocketAfterExecute(running_, 
endpoint, &live_clients_, &mutex_));
       utils::Worker<int> functor(f_ex, "workers", std::move(after_execute));
-      if (client_thread_pool_.execute(std::move(functor), *future)) {
-        live_clients_[endpoint] = future;
-      }
+      auto* future = new 
std::future<int>(client_thread_pool_.execute(std::move(functor)));

Review comment:
       The only place I've seen a `delete` on these future objects are here 
https://github.com/apache/nifi-minifi-cpp/pull/1022/files/a46b3bea392683bda836a9c668289c02810a371a#diff-8d484e99475c978743af82b7ee8ba45954457ecbac4c033744d1cc95ad9f8240R294
   Since `GetTCP::live_clients_` is private I assume it's only deleted here. I 
can check it out to make sure but I think it's safe to rewrite 
`GetTCP::live_clients_` to store `std::unique_ptr`s or simply `std::future`s. 
AFAIK `std::future` is pretty cheap to move.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to