Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify deprecated function.
[simgrid.git] / src / simix / smx_private.hpp
1 /* Copyright (c) 2007-2019. 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/actor/ActorImpl.hpp"
11 #include "src/kernel/context/Context.hpp"
12
13 #include <boost/intrusive/list.hpp>
14 #include <mutex>
15 #include <unordered_map>
16 #include <vector>
17
18 /********************************** Simix Global ******************************/
19
20 namespace simgrid {
21 namespace simix {
22
23 class Global {
24   friend XBT_PUBLIC bool simgrid::s4u::this_actor::is_maestro();
25
26 public:
27   bool execute_tasks();
28   /**
29    * Garbage collection
30    *
31    * Should be called some time to time to free the memory allocated for actors that have finished (or killed).
32    */
33   void empty_trash();
34   void run_all_actors();
35
36   smx_context_factory_t context_factory = nullptr;
37   std::vector<smx_actor_t> actors_to_run;
38   std::vector<smx_actor_t> actors_that_ran;
39   std::map<aid_t, smx_actor_t> process_list;
40   boost::intrusive::list<kernel::actor::ActorImpl,
41                          boost::intrusive::member_hook<kernel::actor::ActorImpl, boost::intrusive::list_member_hook<>,
42                                                        &kernel::actor::ActorImpl::smx_destroy_list_hook>>
43       actors_to_destroy;
44 #if SIMGRID_HAVE_MC
45   /* MCer cannot read members process_list and actors_to_destroy above in the remote process, so we copy the info it
46    * needs in a dynar.
47    * FIXME: This is supposed to be a temporary hack.
48    * A better solution would be to change the split between MCer and MCed, where the responsibility
49    *   to compute the list of the enabled transitions goes to the MCed.
50    * That way, the MCer would not need to have the list of actors on its side.
51    * These info could be published by the MCed to the MCer in a way inspired of vd.so
52    */
53   xbt_dynar_t actors_vector      = xbt_dynar_new(sizeof(smx_actor_t), nullptr);
54   xbt_dynar_t dead_actors_vector = xbt_dynar_new(sizeof(smx_actor_t), nullptr);
55 #endif
56   smx_actor_t maestro_process   = nullptr;
57
58   // Maps function names to actor code:
59   std::unordered_map<std::string, simgrid::simix::ActorCodeFactory> registered_functions;
60
61   // This might be used when no corresponding function name is registered:
62   simgrid::simix::ActorCodeFactory default_function;
63
64   std::mutex mutex;
65
66   std::vector<simgrid::xbt::Task<void()>> tasks;
67   std::vector<simgrid::xbt::Task<void()>> tasksTemp;
68
69   std::vector<simgrid::kernel::actor::ActorImpl*> daemons;
70 };
71 }
72 }
73
74 XBT_PUBLIC_DATA std::unique_ptr<simgrid::simix::Global> simix_global;
75
76 XBT_PUBLIC void SIMIX_clean();
77
78 #endif