Logo AND Algorithmique Numérique Distribuée

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