Logo AND Algorithmique Numérique Distribuée

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