MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / registerCallback

Method registerCallback

libminifi/src/io/ServerSocket.cpp:59–71  ·  view source on GitHub ↗

* Initializes the socket * @return result of the creation operation. */

Source from the content-addressed store, hash-verified

57 * @return result of the creation operation.
58 */
59void ServerSocket::registerCallback(std::function<bool()> accept_function, std::function<void(io::BaseStream *)> handler) {
60 auto fx = [this](std::function<bool()> /*accept_function*/, std::function<void(io::BaseStream *stream)> handler) {
61 while (running_) {
62 int fd = select_descriptor(1000);
63 if (fd >= 0) {
64 io::DescriptorStream stream(fd);
65 handler(&stream);
66 close_fd(fd);
67 }
68 }
69 };
70 server_read_thread_ = std::thread(fx, std::move(accept_function), std::move(handler));
71}
72
73void ServerSocket::close_fd(int fd) {
74 std::lock_guard<std::recursive_mutex> guard(selection_mutex_);

Callers 3

initializeMethod · 0.45
queryRootProcessGroupMethod · 0.45

Calls 1

handlerFunction · 0.85

Tested by 1

queryRootProcessGroupMethod · 0.36