Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into mc
[simgrid.git] / src / mc / mc_server.h
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 MC_SERVER_H
8 #define MC_SERVER_H
9
10 #include <poll.h>
11
12 #include <stdint.h>
13 #include <stdbool.h>
14
15 #include <sys/signalfd.h>
16 #include <sys/types.h>
17
18 #include <xbt/misc.h>
19  
20 #include "mc_process.h"
21
22 SG_BEGIN_DECL()
23
24 #define MC_SERVER_ERROR 127
25
26 typedef struct s_mc_server s_mc_server_t, *mc_server_t;
27
28 extern mc_server_t mc_server;
29
30 void MC_server_wait_client(mc_process_t process);
31 void MC_server_simcall_handle(mc_process_t process, unsigned long pid, int value);
32
33 void MC_server_loop(mc_server_t server);
34
35 SG_END_DECL()
36
37 #ifdef __cplusplus
38
39 struct s_mc_server {
40 private:
41   pid_t pid;
42   int socket;
43   struct pollfd fds[2];
44 public:
45   s_mc_server(pid_t pid, int socket);
46   void start();
47   void shutdown();
48   void exit();
49   void resume(mc_process_t process);
50   void loop();
51   bool handle_events();
52 protected:
53   void handle_signals();
54   void handle_waitpid();
55   void on_signal(const struct signalfd_siginfo* info);
56 };
57
58 #endif
59
60 #endif