Logo AND Algorithmique Numérique Distribuée

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