Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
forgot one include
[simgrid.git] / src / simix / smx_private.h
1 /* Copyright (c) 2007-2010, 2012-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 _SIMIX_PRIVATE_H
8 #define _SIMIX_PRIVATE_H
9
10 #include <signal.h>
11 #include "src/kernel/context/Context.hpp"
12
13 #include <map>
14
15 /********************************** Simix Global ******************************/
16
17 namespace simgrid {
18 namespace simix {
19
20 class Global {
21 public:
22   smx_context_factory_t context_factory = nullptr;
23   xbt_dynar_t process_to_run = nullptr;
24   xbt_dynar_t process_that_ran = nullptr;
25   std::map<int, smx_actor_t> process_list;
26 #if HAVE_MC
27   /* MCer cannot read the std::map above in the remote process, so we copy the info it needs in a dynar.
28    * FIXME: This is supposed to be a temporary hack.
29    * A better solution would be to change the split between MCer and MCed, where the responsibility
30    *   to compute the list of the enabled transitions goes to the MCed.
31    * That way, the MCer would not need to have the list of actors on its side.
32    * These info could be published by the MCed to the MCer in a way inspired of vd.so
33    */
34   xbt_dynar_t actors_vector = xbt_dynar_new(sizeof(smx_actor_t), nullptr);
35 #endif
36   xbt_swag_t process_to_destroy = nullptr;
37   smx_actor_t maestro_process = nullptr;
38
39   // Maps function names to actor code:
40   std::unordered_map<std::string, simgrid::simix::ActorCodeFactory> registered_functions;
41
42   // This might be used when no corresponding function name is registered:
43   simgrid::simix::ActorCodeFactory default_function;
44
45   smx_creation_func_t create_process_function = nullptr;
46   void_pfn_smxprocess_t kill_process_function = nullptr;
47   /** Callback used when killing a SMX_process */
48   void_pfn_smxprocess_t cleanup_process_function = nullptr;
49   xbt_os_mutex_t mutex = nullptr;
50
51   std::vector<simgrid::xbt::Task<void()>> tasks;
52   std::vector<simgrid::xbt::Task<void()>> tasksTemp;
53 };
54
55 }
56 }
57
58 SG_BEGIN_DECL()
59
60 XBT_PUBLIC_DATA(std::unique_ptr<simgrid::simix::Global>) simix_global;
61
62 XBT_PUBLIC(void) SIMIX_clean();
63
64 /******************************** Exceptions *********************************/
65 /** @brief Ask to the provided simix process to raise the provided exception */
66 #define SMX_EXCEPTION(issuer, cat, val, msg) \
67   if (1) { \
68   smx_actor_t _smx_throw_issuer = (issuer); /* evaluate only once */ \
69   xbt_ex e(XBT_THROW_POINT, msg); \
70   e.category = cat; \
71   e.value = val; \
72   _smx_throw_issuer->exception = std::make_exception_ptr(e); \
73   } else ((void)0)
74
75 /* ******************************** File ************************************ */
76 typedef struct s_smx_file {
77   surf_file_t surf_file;
78   void* data;                   /**< @brief user data */
79 } s_smx_file_t;
80
81
82 SG_END_DECL()
83
84 #endif