.. group-tab:: C++
.. autodoxymethod:: simgrid::s4u::Actor::on_exit
- .. autodoxymethod:: simgrid::s4u::Actor::join()
- .. autodoxymethod:: simgrid::s4u::Actor::join(double timeout)
+ .. autodoxymethod:: simgrid::s4u::Actor::join() const
+ .. autodoxymethod:: simgrid::s4u::Actor::join(double timeout) const
.. autodoxymethod:: simgrid::s4u::Actor::set_auto_restart(bool autorestart)
.. group-tab:: Python
.. group-tab:: C
- .. autodoxymethod:: sg_actor_join(sg_actor_t actor, double timeout)
+ .. autodoxymethod:: sg_actor_join(const_sg_actor_t actor, double timeout)
.. autodoxymethod:: sg_actor_set_auto_restart(sg_actor_t actor, int auto_restart)
Signals
.. autodoxymethod:: simgrid::s4u::VirtualMachine::get_pm() const
.. autodoxymethod:: simgrid::s4u::VirtualMachine::get_ramsize() const
- .. autodoxymethod:: simgrid::s4u::VirtualMachine::get_state()
+ .. autodoxymethod:: simgrid::s4u::VirtualMachine::get_state() const
.. autodoxymethod:: simgrid::s4u::VirtualMachine::set_bound(double bound)
.. autodoxymethod:: simgrid::s4u::VirtualMachine::set_pm(Host *pm)
.. autodoxymethod:: simgrid::s4u::Semaphore::acquire()
.. autodoxymethod:: simgrid::s4u::Semaphore::acquire_timeout(double timeout)
- .. autodoxymethod:: simgrid::s4u::Semaphore::get_capacity()
+ .. autodoxymethod:: simgrid::s4u::Semaphore::get_capacity() const
.. autodoxymethod:: simgrid::s4u::Semaphore::release()
- .. autodoxymethod:: simgrid::s4u::Semaphore::would_block()
+ .. autodoxymethod:: simgrid::s4u::Semaphore::would_block() const
.. group-tab:: C
.. autodoxymethod:: sg_sem_acquire(sg_sem_t sem)
.. autodoxymethod:: sg_sem_acquire_timeout(sg_sem_t sem, double timeout)
- .. autodoxymethod:: sg_sem_get_capacity(sg_sem_t sem)
+ .. autodoxymethod:: sg_sem_get_capacity(const_sg_sem_t sem)
.. autodoxymethod:: sg_sem_release(sg_sem_t sem)
- .. autodoxymethod:: sg_sem_would_block(sg_sem_t sem)
+ .. autodoxymethod:: sg_sem_would_block(const_sg_sem_t sem)
.. |hr| raw:: html
static void master(int argc, char* argv[])
{
- sg_actor_t actor;
+ const_sg_actor_t actor;
XBT_INFO("Start sleeper");
actor = sg_actor_create("sleeper from master", sg_host_self(), sleeper, 0, NULL);
#endif
XBT_PUBLIC void sg_actor_set_host(sg_actor_t actor, sg_host_t host);
-XBT_PUBLIC void sg_actor_join(sg_actor_t actor, double timeout);
+XBT_PUBLIC void sg_actor_join(const_sg_actor_t actor, double timeout);
XBT_PUBLIC void sg_actor_kill(sg_actor_t actor);
XBT_PUBLIC void sg_actor_kill_all();
XBT_PUBLIC void sg_actor_set_kill_time(sg_actor_t actor, double kill_time);
* @param process the process to wait for
* @param timeout wait until the process is over, or the timeout occurs
*/
-XBT_PUBLIC void MSG_process_join(msg_process_t process, double timeout);
+XBT_PUBLIC void MSG_process_join(const_sg_actor_t process, double timeout);
/** @brief Kills a process */
XBT_PUBLIC void MSG_process_kill(msg_process_t process);
/** @brief Kill all running process */
XBT_PUBLIC void MSG_sem_acquire(msg_sem_t sem);
XBT_PUBLIC int MSG_sem_acquire_timeout(msg_sem_t sem, double timeout);
XBT_PUBLIC void MSG_sem_release(msg_sem_t sem);
-XBT_PUBLIC int MSG_sem_get_capacity(msg_sem_t sem);
+XBT_PUBLIC int MSG_sem_get_capacity(const_sg_sem_t sem);
XBT_PUBLIC void MSG_sem_destroy(const_sg_sem_t sem);
-XBT_PUBLIC int MSG_sem_would_block(msg_sem_t sem);
+XBT_PUBLIC int MSG_sem_would_block(const_sg_sem_t sem);
/** @brief Opaque type representing a barrier identifier */
typedef sg_bar_t msg_bar_t;
* Blocks the calling actor until the joined actor is terminated. If actor alice executes bob.join(), then alice is
* blocked until bob terminates.
*/
- void join();
+ void join() const;
/** Wait for the actor to finish, or for the timeout to elapse.
*
* Blocks the calling actor until the joined actor is terminated. If actor alice executes bob.join(), then alice is
* blocked until bob terminates.
*/
- void join(double timeout);
+ void join(double timeout) const;
/** Kill that actor and restart it from start. */
Actor* restart();
void acquire();
int acquire_timeout(double timeout);
void release();
- int get_capacity();
- int would_block();
+ int get_capacity() const;
+ int would_block() const;
};
} // namespace s4u
VirtualMachine* set_ramsize(size_t ramsize);
VirtualMachine* set_bound(double bound);
- VirtualMachine::state get_state();
+ VirtualMachine::state get_state() const;
static xbt::signal<void(VirtualMachine const&)> on_start;
static xbt::signal<void(VirtualMachine const&)> on_started;
static xbt::signal<void(VirtualMachine const&)> on_shutdown;
XBT_PUBLIC void sg_sem_acquire(sg_sem_t sem);
XBT_PUBLIC int sg_sem_acquire_timeout(sg_sem_t sem, double timeout);
XBT_PUBLIC void sg_sem_release(sg_sem_t sem);
-XBT_PUBLIC int sg_sem_get_capacity(sg_sem_t sem);
+XBT_PUBLIC int sg_sem_get_capacity(const_sg_sem_t sem);
XBT_PUBLIC void sg_sem_destroy(const_sg_sem_t sem);
-XBT_PUBLIC int sg_sem_would_block(sg_sem_t sem);
+XBT_PUBLIC int sg_sem_would_block(const_sg_sem_t sem);
SG_END_DECL
std::vector<jobject> vms;
for (size_t i = 0; i < host_count; i++) {
- auto* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(hosts[i]);
+ const auto* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(hosts[i]);
if (vm != nullptr && vm->get_state() != simgrid::s4u::VirtualMachine::state::DESTROYED) {
auto jvm = static_cast<jobject>(vm->extension(JAVA_HOST_LEVEL));
vms.push_back(jvm);
.def("is_daemon", &Actor::is_daemon,
"Returns True if that actor is a daemon and will be terminated automatically when the last non-daemon actor "
"terminates.")
- .def("join", py::overload_cast<double>(&Actor::join), py::call_guard<GilScopedRelease>(),
+ .def("join", py::overload_cast<double>(&Actor::join, py::const_), py::call_guard<GilScopedRelease>(),
"Wait for the actor to finish (more info in the C++ documentation).", py::arg("timeout"))
.def("kill", &Actor::kill, py::call_guard<GilScopedRelease>(), "Kill that actor")
.def("kill_all", &Actor::kill_all, py::call_guard<GilScopedRelease>(), "Kill all actors but the caller.")
{
sg_actor_set_host(actor, host);
}
-void MSG_process_join(sg_actor_t actor, double timeout)
+void MSG_process_join(const_sg_actor_t actor, double timeout)
{
sg_actor_join(actor, timeout);
}
{
sg_sem_release(sem);
}
-int MSG_sem_get_capacity(sg_sem_t sem)
+int MSG_sem_get_capacity(const_sg_sem_t sem)
{
return sg_sem_get_capacity(sem);
}
{
sg_sem_destroy(sem);
}
-int MSG_sem_would_block(sg_sem_t sem)
+int MSG_sem_would_block(const_sg_sem_t sem)
{
return sg_sem_would_block(sem);
}
return this;
}
-VirtualMachine::state VirtualMachine::get_state()
+VirtualMachine::state VirtualMachine::get_state() const
{
return kernel::actor::simcall([this]() { return pimpl_vm_->get_state(); });
}
// ***** Actor methods *****
-void Actor::join()
+void Actor::join() const
{
join(-1);
}
-void Actor::join(double timeout)
+void Actor::join(double timeout) const
{
kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
const kernel::actor::ActorImpl* target = pimpl_;
* @param actor the actor to wait for
* @param timeout wait until the actor is over, or the timeout expires
*/
-void sg_actor_join(sg_actor_t actor, double timeout)
+void sg_actor_join(const_sg_actor_t actor, double timeout)
{
actor->join(timeout);
}
kernel::actor::simcall([this] { sem_->release(); });
}
-int Semaphore::get_capacity()
+int Semaphore::get_capacity() const
{
return kernel::actor::simcall([this] { return sem_->get_capacity(); });
}
-int Semaphore::would_block()
+int Semaphore::would_block() const
{
return kernel::actor::simcall([this] { return sem_->would_block(); });
}
sem->release();
}
-int sg_sem_get_capacity(sg_sem_t sem)
+int sg_sem_get_capacity(const_sg_sem_t sem)
{
return sem->get_capacity();
}
* Note that the returned value may be wrong right after the function call, when you try to use it...
* But that's a classical semaphore issue, and SimGrid's semaphore are not different to usual ones here.
*/
-int sg_sem_would_block(sg_sem_t sem)
+int sg_sem_would_block(const_sg_sem_t sem)
{
return sem->would_block();
}