cluster/zeromq: Use lambda for thread trampoline

This commit is contained in:
Arne Welzel 2025-02-05 13:49:06 +01:00
parent 16c745cee4
commit 2c6d934ef4

View file

@ -59,15 +59,6 @@ constexpr DebugFlag operator&(zeek_uint_t x, DebugFlag y) {
} \ } \
} while ( 0 ) } while ( 0 )
namespace {
void self_thread_fun(void* arg) {
auto* self = static_cast<ZeroMQBackend*>(arg);
self->Run();
}
} // namespace
ZeroMQBackend::ZeroMQBackend(std::unique_ptr<EventSerializer> es, std::unique_ptr<LogSerializer> ls, ZeroMQBackend::ZeroMQBackend(std::unique_ptr<EventSerializer> es, std::unique_ptr<LogSerializer> ls,
std::unique_ptr<detail::EventHandlingStrategy> ehs) std::unique_ptr<detail::EventHandlingStrategy> ehs)
: ThreadedBackend(std::move(es), std::move(ls), std::move(ehs)) { : ThreadedBackend(std::move(es), std::move(ls), std::move(ehs)) {
@ -227,7 +218,9 @@ bool ZeroMQBackend::DoInit() {
// Setup connectivity between main and child thread. // Setup connectivity between main and child thread.
main_inproc.bind("inproc://inproc-bridge"); main_inproc.bind("inproc://inproc-bridge");
child_inproc.connect("inproc://inproc-bridge"); child_inproc.connect("inproc://inproc-bridge");
self_thread = std::thread(self_thread_fun, this);
// Thread is joined in backend->DoTerminate(), backend outlives it.
self_thread = std::thread([](auto* backend) { backend->Run(); }, this);
// After connecting, call ThreadedBackend::DoInit() to register // After connecting, call ThreadedBackend::DoInit() to register
// the IO source with the loop. // the IO source with the loop.