1 /* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "src/mc/remote/EventLoop.hpp"
9 simgrid::mc::EventLoop::~EventLoop()
11 if (socket_event_ != nullptr)
12 event_free(socket_event_);
13 if (signal_event_ != nullptr)
14 event_free(signal_event_);
16 event_base_free(base_);
19 void simgrid::mc::EventLoop::start(int socket, void (*handler)(int, short, void*))
21 base_ = event_base_new();
23 socket_event_ = event_new(base_, socket, EV_READ | EV_PERSIST, handler, this);
24 event_add(socket_event_, NULL);
26 signal_event_ = event_new(base_, SIGCHLD, EV_SIGNAL | EV_PERSIST, handler, this);
27 event_add(signal_event_, NULL);
30 void simgrid::mc::EventLoop::dispatch()
32 event_base_dispatch(base_);
35 void simgrid::mc::EventLoop::break_loop()
37 event_base_loopbreak(base_);