martinzink commented on code in PR #1595:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1595#discussion_r1247524864


##########
libminifi/src/c2/ControllerSocketProtocol.cpp:
##########
@@ -66,7 +69,49 @@ 
ControllerSocketProtocol::ControllerSocketProtocol(core::controller::ControllerS
         configuration_(std::move(configuration)),
         socket_restart_processor_(update_sink_) {
   gsl_Expects(configuration_);
-  stream_factory_ = minifi::io::StreamFactory::getInstance(configuration_);
+}
+
+ControllerSocketProtocol::~ControllerSocketProtocol() {
+  stopListener();
+}
+
+void ControllerSocketProtocol::stopListener() {
+  io_context_.stop();
+  if (acceptor_) {
+    acceptor_->close();
+  }
+  if (server_thread_.joinable()) {
+    server_thread_.join();
+  }
+  io_context_.restart();
+}
+
+void ControllerSocketProtocol::startAccept() {
+  acceptor_->async_accept([this](const asio::error_code& error, 
asio::ip::tcp::socket socket) {

Review Comment:
   I think you should consider using the coroutines instead.
   That would remove the need for callbacks and as far as I know the 
performance is much better aswell.
   
   It should be fairly easy to rewrite these using coro. There is a great 
tutorial by the author of asio.
   https://www.youtube.com/watch?v=icgnqFM-aY4



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

Reply via email to