Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
monkey-workers: reduce the amount of simcalls during reboots
[simgrid.git] / src / simix / popping_bodies.cpp
1 /**********************************************************************/
2 /* File generated by src/simix/simcalls.py from src/simix/simcalls.in */
3 /*                                                                    */
4 /*                    DO NOT EVER CHANGE THIS FILE                    */
5 /*                                                                    */
6 /* change simcalls specification in src/simix/simcalls.in             */
7 /* Copyright (c) 2014-2022. The SimGrid Team. All rights reserved.    */
8 /**********************************************************************/
9
10 /*
11  * Note that the name comes from http://en.wikipedia.org/wiki/Popping
12  * Indeed, the control flow is doing a strange dance in there.
13  *
14  * That's not about http://en.wikipedia.org/wiki/Poop, despite the odor :)
15  */
16
17 #include "src/kernel/EngineImpl.hpp"
18 #include "src/kernel/actor/ActorImpl.hpp"
19 #include "src/mc/mc_forward.hpp"
20 #include "xbt/ex.h"
21 #include <functional>
22 #include <simgrid/simix.hpp>
23 #include <xbt/log.h>
24 /** @cond */ // Please Doxygen, don't look at this
25
26 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
27
28 using simgrid::simix::Simcall;
29
30 template<class R, class... T>
31 inline static R simcall(Simcall call, T const&... t)
32 {
33   auto self = simgrid::kernel::actor::ActorImpl::self();
34   simgrid::simix::marshal(&self->simcall_, call, t...);
35   if (not simgrid::kernel::EngineImpl::get_instance()->is_maestro(self)) {
36     XBT_DEBUG("Yield process '%s' on simcall %s", self->get_cname(), SIMIX_simcall_name(self->simcall_));
37     self->yield();
38   } else {
39     self->simcall_handle(0);
40   }
41   return simgrid::simix::unmarshal<R>(self->simcall_.result_);
42 }
43
44 inline static void simcall_BODY_run_kernel(std::function<void()> const* code)
45 {
46   if (false) /* Go to that function to follow the code flow through the simcall barrier */
47     SIMIX_run_kernel(code);
48   return simcall<void, std::function<void()> const*>(Simcall::RUN_KERNEL, code);
49 }
50
51 inline static void simcall_BODY_run_blocking(std::function<void()> const* code)
52 {
53   if (false) /* Go to that function to follow the code flow through the simcall barrier */
54     SIMIX_run_blocking(code);
55   return simcall<void, std::function<void()> const*>(Simcall::RUN_BLOCKING, code);
56 }
57 /** @endcond */