event/SignalMonitor: use BoundMethod instead of raw function pointer

This commit is contained in:
Max Kellermann
2016-06-20 10:25:28 +02:00
parent c3d9c32615
commit 4280f84535
4 changed files with 18 additions and 14 deletions

View File

@@ -27,17 +27,18 @@
#include <signal.h>
static void
HandleShutdownSignal()
HandleShutdownSignal(void *ctx)
{
SignalMonitorGetEventLoop().Break();
auto &loop = *(EventLoop *)ctx;
loop.Break();
}
ShutdownHandler::ShutdownHandler(EventLoop &loop)
{
SignalMonitorInit(loop);
SignalMonitorRegister(SIGINT, HandleShutdownSignal);
SignalMonitorRegister(SIGTERM, HandleShutdownSignal);
SignalMonitorRegister(SIGINT, {&loop, HandleShutdownSignal});
SignalMonitorRegister(SIGTERM, {&loop, HandleShutdownSignal});
}
ShutdownHandler::~ShutdownHandler()