Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Move Server in simgrid::mc
[simgrid.git] / src / mc / Server.hpp
1 /* Copyright (c) 2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SIMGRID_MC_SERVER_HPP
8 #define SIMGRID_MC_SERVER_HPP
9
10 #include <poll.h>
11
12 #include <sys/signalfd.h>
13 #include <sys/types.h>
14
15 #include <xbt/misc.h>
16 #include <xbt/base.h>
17  
18 #include "src/mc/Process.hpp"
19 #include "mc_exit.h"
20
21 namespace simgrid {
22 namespace mc {
23
24 class Server {
25 private:
26   pid_t pid;
27   int socket;
28   struct pollfd fds[2];
29 public:
30   Server(pid_t pid, int socket);
31   void start();
32   void shutdown();
33   void exit();
34   void resume(simgrid::mc::Process& process);
35   void loop();
36   bool handle_events();
37   void wait_client(simgrid::mc::Process& process);
38   void simcall_handle(simgrid::mc::Process& process, unsigned long pid, int value);
39 private:
40   bool handle_message(char* buffer, ssize_t size);
41   void handle_signals();
42   void handle_waitpid();
43   void on_signal(const struct signalfd_siginfo* info);
44 };
45
46 extern Server* server;
47
48 }
49 }
50
51 #endif