mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
cluster/zeromq: Use lambda for thread trampoline
This commit is contained in:
parent
16c745cee4
commit
2c6d934ef4
1 changed files with 3 additions and 10 deletions
|
@ -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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue