Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Explicit instanciation of xbt::Extendable<> specializations.
[simgrid.git] / src / s4u / s4u_Actor.cpp
1 /* Copyright (c) 2006-2020. 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 #include "simgrid/Exception.hpp"
7 #include "simgrid/actor.h"
8 #include "simgrid/modelchecker.h"
9 #include "simgrid/s4u/Actor.hpp"
10 #include "simgrid/s4u/Exec.hpp"
11 #include "simgrid/s4u/Host.hpp"
12 #include "simgrid/s4u/VirtualMachine.hpp"
13 #include "src/include/mc/mc.h"
14 #include "src/kernel/activity/ExecImpl.hpp"
15 #include "src/mc/mc_replay.hpp"
16 #include "src/surf/HostImpl.hpp"
17
18 #include <algorithm>
19 #include <sstream>
20
21 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_actor, s4u, "S4U actors");
22
23 namespace simgrid {
24
25 template class xbt::Extendable<s4u::Actor>;
26
27 namespace s4u {
28
29 xbt::signal<void(Actor&)> s4u::Actor::on_creation;
30 xbt::signal<void(Actor const&)> s4u::Actor::on_suspend;
31 xbt::signal<void(Actor const&)> s4u::Actor::on_resume;
32 xbt::signal<void(Actor const&)> s4u::Actor::on_sleep;
33 xbt::signal<void(Actor const&)> s4u::Actor::on_wake_up;
34 xbt::signal<void(Actor const&)> s4u::Actor::on_migration_start; // deprecated
35 xbt::signal<void(Actor const&)> s4u::Actor::on_migration_end;   // deprecated
36 xbt::signal<void(Actor const&, Host const& previous_location)> s4u::Actor::on_host_change;
37 xbt::signal<void(Actor const&)> s4u::Actor::on_termination;
38 xbt::signal<void(Actor const&)> s4u::Actor::on_destruction;
39
40 // ***** Actor creation *****
41 Actor* Actor::self()
42 {
43   kernel::context::Context* self_context = kernel::context::Context::self();
44   if (self_context == nullptr)
45     return nullptr;
46
47   return self_context->get_actor()->ciface();
48 }
49
50 ActorPtr Actor::init(const std::string& name, s4u::Host* host)
51 {
52   kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
53   kernel::actor::ActorImpl* actor =
54       kernel::actor::simcall([self, &name, host] { return self->init(name, host).get(); });
55   return actor->iface();
56 }
57
58 ActorPtr Actor::start(const std::function<void()>& code)
59 {
60   simgrid::kernel::actor::simcall([this, &code] { pimpl_->start(code); });
61   return this;
62 }
63
64 ActorPtr Actor::create(const std::string& name, s4u::Host* host, const std::function<void()>& code)
65 {
66   kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
67   kernel::actor::ActorImpl* actor =
68       kernel::actor::simcall([self, &name, host, &code] { return self->init(name, host)->start(code); });
69
70   return actor->iface();
71 }
72
73 ActorPtr Actor::create(const std::string& name, s4u::Host* host, const std::string& function,
74                        std::vector<std::string> args)
75 {
76   const simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
77   return create(name, host, factory(std::move(args)));
78 }
79
80 void intrusive_ptr_add_ref(const Actor* actor)
81 {
82   intrusive_ptr_add_ref(actor->pimpl_);
83 }
84 void intrusive_ptr_release(const Actor* actor)
85 {
86   intrusive_ptr_release(actor->pimpl_);
87 }
88 int Actor::get_refcount()
89 {
90   return pimpl_->get_refcount();
91 }
92
93 // ***** Actor methods *****
94
95 void Actor::join()
96 {
97   join(-1);
98 }
99
100 void Actor::join(double timeout)
101 {
102   kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
103   kernel::actor::ActorImpl* target = pimpl_;
104   kernel::actor::simcall_blocking<void>([issuer, target, timeout] {
105     if (target->finished_) {
106       // The joined process is already finished, just wake up the issuer right away
107       issuer->simcall_answer();
108     } else {
109       smx_activity_t sync = issuer->join(target, timeout);
110       sync->register_simcall(&issuer->simcall);
111     }
112   });
113 }
114
115 void Actor::set_auto_restart(bool autorestart)
116 {
117   kernel::actor::simcall([this, autorestart]() {
118     xbt_assert(autorestart && not pimpl_->has_to_auto_restart()); // FIXME: handle all cases
119     pimpl_->set_auto_restart(autorestart);
120
121     kernel::actor::ProcessArg* arg = new kernel::actor::ProcessArg(pimpl_->get_host(), pimpl_);
122     XBT_DEBUG("Adding %s to the actors_at_boot_ list of Host %s", arg->name.c_str(), arg->host->get_cname());
123     pimpl_->get_host()->pimpl_->add_actor_at_boot(arg);
124   });
125 }
126
127 void Actor::on_exit(const std::function<void(bool /*failed*/)>& fun) const
128 {
129   kernel::actor::simcall([this, &fun] { pimpl_->on_exit->emplace_back(fun); });
130 }
131
132 void Actor::set_host(Host* new_host)
133 {
134   if (s4u::Actor::on_migration_start.get_slot_count() > 0) { // XBT_ATTRIB_DEPRECATED_v329
135     static bool already_warned = false;
136     if (not already_warned) {
137       XBT_INFO("Please use s4u::Actor::on_host_change instead of s4u::Actor::on_migration_start. This will be removed "
138                "in v3.29");
139       already_warned = true;
140     }
141     s4u::Actor::on_migration_start(*this);
142   }
143
144   const s4u::Host* previous_location = get_host();
145
146   kernel::actor::simcall([this, new_host]() {
147     if (pimpl_->waiting_synchro != nullptr) {
148       // The actor is blocked on an activity. If it's an exec, migrate it too.
149       // FIXME: implement the migration of other kinds of activities
150       kernel::activity::ExecImplPtr exec =
151           boost::dynamic_pointer_cast<kernel::activity::ExecImpl>(pimpl_->waiting_synchro);
152       xbt_assert(exec.get() != nullptr, "We can only migrate blocked actors when they are blocked on executions.");
153       exec->migrate(new_host);
154     }
155     this->pimpl_->set_host(new_host);
156   });
157
158   if (s4u::Actor::on_migration_end.get_slot_count() > 0) { // XBT_ATTRIB_DEPRECATED_v329
159     static bool already_warned = false;
160     if (not already_warned) {
161       XBT_INFO("Please use s4u::Actor::on_host_change instead of s4u::Actor::on_migration_end. This will be removed in "
162                "v3.29");
163       already_warned = true;
164     }
165     s4u::Actor::on_migration_end(*this);
166   }
167
168   s4u::Actor::on_host_change(*this, *previous_location);
169 }
170
171 s4u::Host* Actor::get_host() const
172 {
173   return this->pimpl_->get_host();
174 }
175
176 void Actor::daemonize()
177 {
178   kernel::actor::simcall([this]() { pimpl_->daemonize(); });
179 }
180
181 bool Actor::is_daemon() const
182 {
183   return this->pimpl_->is_daemon();
184 }
185
186 const simgrid::xbt::string& Actor::get_name() const
187 {
188   return this->pimpl_->get_name();
189 }
190
191 const char* Actor::get_cname() const
192 {
193   return this->pimpl_->get_cname();
194 }
195
196 aid_t Actor::get_pid() const
197 {
198   return this->pimpl_->get_pid();
199 }
200
201 aid_t Actor::get_ppid() const
202 {
203   return this->pimpl_->get_ppid();
204 }
205
206 void Actor::suspend()
207 {
208   kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
209   kernel::actor::ActorImpl* target = pimpl_;
210   s4u::Actor::on_suspend(*this);
211   kernel::actor::simcall_blocking<void>([issuer, target]() {
212     target->suspend();
213     if (target != issuer) {
214       /* If we are suspending ourselves, then just do not finish the simcall now */
215       issuer->simcall_answer();
216     }
217   });
218 }
219
220 void Actor::resume()
221 {
222   kernel::actor::simcall([this] { pimpl_->resume(); });
223   s4u::Actor::on_resume(*this);
224 }
225
226 bool Actor::is_suspended()
227 {
228   return pimpl_->is_suspended();
229 }
230
231 void Actor::set_kill_time(double kill_time)
232 {
233   kernel::actor::simcall([this, kill_time] { pimpl_->set_kill_time(kill_time); });
234 }
235
236 /** @brief Get the kill time of an actor(or 0 if unset). */
237 double Actor::get_kill_time()
238 {
239   return pimpl_->get_kill_time();
240 }
241
242 void Actor::kill()
243 {
244   kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
245   kernel::actor::simcall([this, self] { self->kill(pimpl_); });
246 }
247
248 // ***** Static functions *****
249
250 ActorPtr Actor::by_pid(aid_t pid)
251 {
252   kernel::actor::ActorImpl* actor = SIMIX_process_from_PID(pid);
253   if (actor != nullptr)
254     return actor->iface();
255   else
256     return ActorPtr();
257 }
258
259 void Actor::kill_all()
260 {
261   kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
262   kernel::actor::simcall([self] { self->kill_all(); });
263 }
264
265 const std::unordered_map<std::string, std::string>* Actor::get_properties() const
266 {
267   return pimpl_->get_properties();
268 }
269
270 /** Retrieve the property value (or nullptr if not set) */
271 const char* Actor::get_property(const std::string& key) const
272 {
273   return pimpl_->get_property(key);
274 }
275
276 void Actor::set_property(const std::string& key, const std::string& value)
277 {
278   kernel::actor::simcall([this, &key, &value] { pimpl_->set_property(key, value); });
279 }
280
281 Actor* Actor::restart()
282 {
283   return kernel::actor::simcall([this]() { return pimpl_->restart(); });
284 }
285
286 // ***** this_actor *****
287
288 namespace this_actor {
289
290 /** Returns true if run from the kernel mode, and false if run from a real actor
291  *
292  * Everything that is run out of any actor (simulation setup before the engine is run,
293  * computing the model evolutions as a result to the actors' action, etc) is run in
294  * kernel mode, just as in any operating systems.
295  *
296  * In SimGrid, the actor in charge of doing the stuff in kernel mode is called Maestro,
297  * because it is the one scheduling when the others should move or wait.
298  */
299 bool is_maestro()
300 {
301   return SIMIX_is_maestro();
302 }
303
304 void sleep_for(double duration)
305 {
306   xbt_assert(std::isfinite(duration), "duration is not finite!");
307
308   if (duration > 0) {
309     kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
310     Actor::on_sleep(*issuer->ciface());
311
312     kernel::actor::simcall_blocking<void>([issuer, duration]() {
313       if (MC_is_active() || MC_record_replay_is_active()) {
314         MC_process_clock_add(issuer, duration);
315         issuer->simcall_answer();
316         return;
317       }
318       smx_activity_t sync = issuer->sleep(duration);
319       sync->register_simcall(&issuer->simcall);
320     });
321
322     Actor::on_wake_up(*issuer->ciface());
323   }
324 }
325
326 void yield()
327 {
328   kernel::actor::simcall([] { /* do nothing*/ });
329 }
330
331 XBT_PUBLIC void sleep_until(double wakeup_time)
332 {
333   double now = SIMIX_get_clock();
334   if (wakeup_time > now)
335     sleep_for(wakeup_time - now);
336 }
337
338 void execute(double flops)
339 {
340   execute(flops, 1.0 /* priority */);
341 }
342
343 void execute(double flops, double priority)
344 {
345   exec_init(flops)->set_priority(priority)->start()->wait();
346 }
347
348 void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
349                       const std::vector<double>& bytes_amounts)
350 {
351   exec_init(hosts, flops_amounts, bytes_amounts)->wait();
352 }
353
354 void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
355                       const std::vector<double>& bytes_amounts, double timeout) // XBT_ATTRIB_DEPRECATED_v329
356 {
357   exec_init(hosts, flops_amounts, bytes_amounts)->wait_for(timeout);
358 }
359
360 ExecPtr exec_init(double flops_amount)
361 {
362   return ExecPtr(new ExecSeq(get_host(), flops_amount));
363 }
364
365 ExecPtr exec_init(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
366                   const std::vector<double>& bytes_amounts)
367 {
368   xbt_assert(hosts.size() > 0, "Your parallel executions must span over at least one host.");
369   xbt_assert(hosts.size() == flops_amounts.size() || flops_amounts.empty(),
370              "Host count (%zu) does not match flops_amount count (%zu).", hosts.size(), flops_amounts.size());
371   xbt_assert(hosts.size() * hosts.size() == bytes_amounts.size() || bytes_amounts.empty(),
372              "bytes_amounts must be a matrix of size host_count * host_count (%zu*%zu), but it's of size %zu.",
373              hosts.size(), hosts.size(), flops_amounts.size());
374   /* Check that we are not mixing VMs and PMs in the parallel task */
375   bool is_a_vm = (nullptr != dynamic_cast<VirtualMachine*>(hosts.front()));
376   xbt_assert(std::all_of(hosts.begin(), hosts.end(),
377                          [is_a_vm](s4u::Host* elm) {
378                            bool tmp_is_a_vm = (nullptr != dynamic_cast<VirtualMachine*>(elm));
379                            return is_a_vm == tmp_is_a_vm;
380                          }),
381              "parallel_execute: mixing VMs and PMs is not supported (yet).");
382   /* checking for infinite values */
383   xbt_assert(std::all_of(flops_amounts.begin(), flops_amounts.end(), [](double elm) { return std::isfinite(elm); }),
384              "flops_amounts comprises infinite values!");
385   xbt_assert(std::all_of(bytes_amounts.begin(), bytes_amounts.end(), [](double elm) { return std::isfinite(elm); }),
386              "flops_amounts comprises infinite values!");
387
388   return ExecPtr(new ExecPar(hosts, flops_amounts, bytes_amounts));
389 }
390
391 ExecPtr exec_async(double flops)
392 {
393   ExecPtr res = exec_init(flops);
394   res->start();
395   return res;
396 }
397
398 aid_t get_pid()
399 {
400   return simgrid::kernel::actor::ActorImpl::self()->get_pid();
401 }
402
403 aid_t get_ppid()
404 {
405   return simgrid::kernel::actor::ActorImpl::self()->get_ppid();
406 }
407
408 std::string get_name()
409 {
410   return simgrid::kernel::actor::ActorImpl::self()->get_name();
411 }
412
413 const char* get_cname()
414 {
415   return simgrid::kernel::actor::ActorImpl::self()->get_cname();
416 }
417
418 Host* get_host()
419 {
420   return simgrid::kernel::actor::ActorImpl::self()->get_host();
421 }
422
423 void suspend()
424 {
425   kernel::actor::ActorImpl* self = simgrid::kernel::actor::ActorImpl::self();
426   s4u::Actor::on_suspend(*self->ciface());
427   kernel::actor::simcall_blocking<void>([self] { self->suspend(); });
428 }
429
430 void resume()
431 {
432   kernel::actor::ActorImpl* self = simgrid::kernel::actor::ActorImpl::self();
433   kernel::actor::simcall([self] { self->resume(); });
434   Actor::on_resume(*self->ciface());
435 }
436
437 void exit()
438 {
439   kernel::actor::ActorImpl* self = simgrid::kernel::actor::ActorImpl::self();
440   simgrid::kernel::actor::simcall([self] { self->exit(); });
441 }
442
443 void on_exit(const std::function<void(bool)>& fun)
444 {
445   simgrid::kernel::actor::ActorImpl::self()->iface()->on_exit(fun);
446 }
447
448 /** @brief Moves the current actor to another host
449  *
450  * @see simgrid::s4u::Actor::migrate() for more information
451  */
452 void set_host(Host* new_host)
453 {
454   simgrid::kernel::actor::ActorImpl::self()->iface()->set_host(new_host);
455 }
456 void migrate(Host* new_host) // deprecated
457 {
458   set_host(new_host);
459 }
460
461 } // namespace this_actor
462 } // namespace s4u
463 } // namespace simgrid
464
465 /* **************************** Public C interface *************************** */
466
467 sg_actor_t sg_actor_init(const char* name, sg_host_t host)
468 {
469   return simgrid::s4u::Actor::init(name, host).get();
470 }
471
472 void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char** argv)
473 {
474   simgrid::simix::ActorCode function;
475   if (code)
476     function = simgrid::xbt::wrap_main(code, argc, static_cast<const char* const*>(argv));
477   actor->start(std::move(function));
478 }
479
480 /** @ingroup m_actor_management
481  * @brief Returns the process ID of @a actor.
482  *
483  * This function checks whether @a actor is a valid pointer and return its PID (or 0 in case of problem).
484  */
485 aid_t sg_actor_get_PID(const_sg_actor_t actor)
486 {
487   /* Do not raise an exception here: this function is called by the logs
488    * and the exceptions, so it would be called back again and again */
489   if (actor == nullptr || actor->get_impl() == nullptr)
490     return 0;
491   return actor->get_pid();
492 }
493
494 /** @ingroup m_actor_management
495  * @brief Returns the process ID of the parent of @a actor.
496  *
497  * This function checks whether @a actor is a valid pointer and return its parent's PID.
498  * Returns -1 if the actor has not been created by any other actor.
499  */
500 aid_t sg_actor_get_PPID(const_sg_actor_t actor)
501 {
502   return actor->get_ppid();
503 }
504
505 /** @ingroup m_actor_management
506  *
507  * @brief Return a #sg_actor_t given its PID.
508  *
509  * This function search in the list of all the created sg_actor_t for a sg_actor_t  whose PID is equal to @a PID.
510  * If none is found, @c nullptr is returned.
511    Note that the PID are unique in the whole simulation, not only on a given host.
512  */
513 sg_actor_t sg_actor_by_PID(aid_t pid)
514 {
515   return simgrid::s4u::Actor::by_pid(pid).get();
516 }
517
518 /** @ingroup m_actor_management
519  * @brief Return the name of an actor.
520  */
521 const char* sg_actor_get_name(const_sg_actor_t actor)
522 {
523   return actor->get_cname();
524 }
525
526 sg_host_t sg_actor_get_host(const_sg_actor_t actor)
527 {
528   return actor->get_host();
529 }
530
531 /** @ingroup m_actor_management
532  * @brief Returns the value of a given actor property
533  *
534  * @param actor an actor
535  * @param name a property name
536  * @return value of a property (or nullptr if the property is not set)
537  */
538 const char* sg_actor_get_property_value(const_sg_actor_t actor, const char* name)
539 {
540   return actor->get_property(name);
541 }
542
543 /** @ingroup m_actor_management
544  * @brief Return the list of properties
545  *
546  * This function returns all the parameters associated with an actor
547  */
548 xbt_dict_t sg_actor_get_properties(const_sg_actor_t actor)
549 {
550   xbt_assert(actor != nullptr, "Invalid parameter: First argument must not be nullptr");
551   xbt_dict_t as_dict                        = xbt_dict_new_homogeneous(xbt_free_f);
552   const std::unordered_map<std::string, std::string>* props = actor->get_properties();
553   if (props == nullptr)
554     return nullptr;
555   for (auto const& kv : *props) {
556     xbt_dict_set(as_dict, kv.first.c_str(), xbt_strdup(kv.second.c_str()));
557   }
558   return as_dict;
559 }
560
561 /** @ingroup m_actor_management
562  * @brief Suspend the actor.
563  *
564  * This function suspends the actor by suspending the task on which it was waiting for the completion.
565  */
566 void sg_actor_suspend(sg_actor_t actor)
567 {
568   xbt_assert(actor != nullptr, "Invalid parameter: First argument must not be nullptr");
569   actor->suspend();
570 }
571
572 /** @ingroup m_actor_management
573  * @brief Resume a suspended actor.
574  *
575  * This function resumes a suspended actor by resuming the task on which it was waiting for the completion.
576  */
577 void sg_actor_resume(sg_actor_t actor)
578 {
579   xbt_assert(actor != nullptr, "Invalid parameter: First argument must not be nullptr");
580   actor->resume();
581 }
582
583 /** @ingroup m_actor_management
584  * @brief Returns true if the actor is suspended .
585  *
586  * This checks whether an actor is suspended or not by inspecting the task on which it was waiting for the completion.
587  */
588 int sg_actor_is_suspended(sg_actor_t actor)
589 {
590   return actor->is_suspended();
591 }
592
593 /**
594  * @ingroup m_actor_management
595  * @brief Restarts an actor from the beginning.
596  */
597 sg_actor_t sg_actor_restart(sg_actor_t actor)
598 {
599   return actor->restart();
600 }
601
602 /**
603  * @ingroup m_actor_management
604  * @brief Sets the "auto-restart" flag of the actor.
605  * If the flag is set to 1, the actor will be automatically restarted when its host comes back up.
606  */
607 void sg_actor_set_auto_restart(sg_actor_t actor, int auto_restart)
608 {
609   actor->set_auto_restart(auto_restart);
610 }
611
612 /** @ingroup m_actor_management
613  * @brief This actor will be terminated automatically when the last non-daemon actor finishes
614  */
615 void sg_actor_daemonize(sg_actor_t actor)
616 {
617   actor->daemonize();
618 }
619
620 /** @ingroup m_actor_management
621  * @brief Migrates an actor to another location.
622  *
623  * This function changes the value of the #sg_host_t on  which @a actor is running.
624  */
625 void sg_actor_set_host(sg_actor_t actor, sg_host_t host)
626 {
627   actor->set_host(host);
628 }
629 void sg_actor_migrate(sg_actor_t process, sg_host_t host) // deprecated
630 {
631   process->set_host(host);
632 }
633
634 /** @ingroup m_actor_management
635  * @brief Wait for the completion of a #sg_actor_t.
636  *
637  * @param actor the actor to wait for
638  * @param timeout wait until the actor is over, or the timeout expires
639  */
640 void sg_actor_join(sg_actor_t actor, double timeout)
641 {
642   actor->join(timeout);
643 }
644
645 void sg_actor_kill(sg_actor_t actor)
646 {
647   actor->kill();
648 }
649
650 void sg_actor_kill_all()
651 {
652   simgrid::s4u::Actor::kill_all();
653 }
654
655 /** @ingroup m_actor_management
656  * @brief Set the kill time of an actor.
657  *
658  * @param actor an actor
659  * @param kill_time the time when the actor is killed.
660  */
661 void sg_actor_set_kill_time(sg_actor_t actor, double kill_time)
662 {
663   actor->set_kill_time(kill_time);
664 }
665
666 /** Yield the current actor; let the other actors execute first */
667 void sg_actor_yield()
668 {
669   simgrid::s4u::this_actor::yield();
670 }
671
672 void sg_actor_sleep_for(double duration)
673 {
674   simgrid::s4u::this_actor::sleep_for(duration);
675 }
676
677 sg_actor_t sg_actor_attach(const char* name, void* data, sg_host_t host, xbt_dict_t properties)
678 {
679   xbt_assert(host != nullptr, "Invalid parameters: host and code params must not be nullptr");
680   std::unordered_map<std::string, std::string> props;
681   xbt_dict_cursor_t cursor = nullptr;
682   char* key;
683   char* value;
684   xbt_dict_foreach (properties, cursor, key, value)
685     props[key] = value;
686   xbt_dict_free(&properties);
687
688   /* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
689   smx_actor_t actor = nullptr;
690   try {
691     actor = simgrid::kernel::actor::ActorImpl::attach(name, data, host, &props).get();
692   } catch (simgrid::HostFailureException const&) {
693     xbt_die("Could not attach");
694   }
695
696   simgrid::s4u::this_actor::yield();
697   return actor->ciface();
698 }
699
700 void sg_actor_detach()
701 {
702   simgrid::kernel::actor::ActorImpl::detach();
703 }
704
705 aid_t sg_actor_self_get_pid()
706 {
707   return simgrid::s4u::this_actor::get_pid();
708 }
709
710 aid_t sg_actor_self_get_ppid()
711 {
712   return simgrid::s4u::this_actor::get_ppid();
713 }
714
715 const char* sg_actor_self_get_name()
716 {
717   return simgrid::s4u::this_actor::get_cname();
718 }
719
720 void* sg_actor_self_data()
721 {
722   return simgrid::s4u::Actor::self()->get_data();
723 }
724
725 void sg_actor_self_data_set(void* userdata)
726 {
727   simgrid::s4u::Actor::self()->set_data(userdata);
728 }
729
730 sg_actor_t sg_actor_self()
731 {
732   return simgrid::s4u::Actor::self();
733 }
734
735 void sg_actor_self_execute(double flops)
736 {
737   simgrid::s4u::this_actor::execute(flops);
738 }
739
740 /** @brief Take an extra reference on that actor to prevent it to be garbage-collected */
741 void sg_actor_ref(const_sg_actor_t actor)
742 {
743   intrusive_ptr_add_ref(actor);
744 }
745 /** @brief Release a reference on that actor so that it can get be garbage-collected */
746 void sg_actor_unref(const_sg_actor_t actor)
747 {
748   intrusive_ptr_release(actor);
749 }
750
751 /** @brief Return the user data of a #sg_actor_t */
752 void* sg_actor_data(const_sg_actor_t actor)
753 {
754   return actor->get_data();
755 }
756 /** @brief Set the user data of a #sg_actor_t */
757 void sg_actor_data_set(sg_actor_t actor, void* userdata)
758 {
759   actor->set_data(userdata);
760 }