Logo AND Algorithmique Numérique Distribuée

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