Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ddf9816859f2fae57b1a19fd63b0e943d6a732a3
[simgrid.git] / src / simix / smx_private.hpp
1 /* Copyright (c) 2007-2021. 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 public:
25   /**
26    * Garbage collection
27    *
28    * Should be called some time to time to free the memory allocated for actors that have finished (or killed).
29    */
30   void empty_trash();
31   void display_all_actor_status() const;
32
33   kernel::context::ContextFactory* context_factory = nullptr;
34   std::map<aid_t, kernel::actor::ActorImpl*> process_list;
35   boost::intrusive::list<kernel::actor::ActorImpl,
36                          boost::intrusive::member_hook<kernel::actor::ActorImpl, boost::intrusive::list_member_hook<>,
37                                                        &kernel::actor::ActorImpl::smx_destroy_list_hook>>
38       actors_to_destroy;
39 #if SIMGRID_HAVE_MC
40   /* MCer cannot read members process_list and actors_to_destroy above in the remote process, so we copy the info it
41    * needs in a dynar.
42    * FIXME: This is supposed to be a temporary hack.
43    * A better solution would be to change the split between MCer and MCed, where the responsibility
44    *   to compute the list of the enabled transitions goes to the MCed.
45    * That way, the MCer would not need to have the list of actors on its side.
46    * These info could be published by the MCed to the MCer in a way inspired of vd.so
47    */
48   xbt_dynar_t actors_vector      = xbt_dynar_new(sizeof(kernel::actor::ActorImpl*), nullptr);
49   xbt_dynar_t dead_actors_vector = xbt_dynar_new(sizeof(kernel::actor::ActorImpl*), nullptr);
50 #endif
51   kernel::actor::ActorImpl* maestro_ = nullptr;
52
53   std::mutex mutex;
54 };
55 }
56 }
57
58 XBT_PUBLIC_DATA std::unique_ptr<simgrid::simix::Global> simix_global;
59
60 XBT_PUBLIC void SIMIX_clean();
61
62 #endif