Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
More const.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 18 Nov 2020 14:06:09 +0000 (15:06 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 18 Nov 2020 15:57:30 +0000 (16:57 +0100)
14 files changed:
docs/source/app_s4u.rst
examples/c/actor-join/actor-join.c
include/simgrid/actor.h
include/simgrid/msg.h
include/simgrid/s4u/Actor.hpp
include/simgrid/s4u/Semaphore.hpp
include/simgrid/s4u/VirtualMachine.hpp
include/simgrid/semaphore.h
src/bindings/java/jmsg_vm.cpp
src/bindings/python/simgrid_python.cpp
src/msg/msg_legacy.cpp
src/plugins/vm/s4u_VirtualMachine.cpp
src/s4u/s4u_Actor.cpp
src/s4u/s4u_Semaphore.cpp

index e241839..be046e3 100644 (file)
@@ -579,8 +579,8 @@ Reacting to the end of actors
    .. 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
@@ -589,7 +589,7 @@ Reacting to the end of actors
 
    .. 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
@@ -1625,7 +1625,7 @@ Querying info
 
       .. 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)
@@ -2168,17 +2168,17 @@ Locking
 
          .. 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
 
index fdbd215..efdaa19 100644 (file)
@@ -22,7 +22,7 @@ static void sleeper(int argc, char* argv[])
 
 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);
index 3278ef6..6fb3693 100644 (file)
@@ -56,7 +56,7 @@ XBT_ATTRIB_DEPRECATED_v329("Please use sg_actor_set_host() instead") XBT_PUBLIC
 #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);
index 33ab45c..b39a672 100644 (file)
@@ -223,7 +223,7 @@ XBT_PUBLIC void MSG_process_migrate(msg_process_t process, msg_host_t host);
  * @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 */
@@ -435,9 +435,9 @@ XBT_PUBLIC msg_sem_t MSG_sem_init(int initial_value);
 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;
index a4b6438..0f8b058 100644 (file)
@@ -207,14 +207,14 @@ public:
    * 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();
 
index 602553d..c3296bf 100644 (file)
@@ -50,8 +50,8 @@ public:
   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
index 1ef5069..f228203 100644 (file)
@@ -54,7 +54,7 @@ public:
   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;
index 730a089..ad11cac 100644 (file)
@@ -16,9 +16,9 @@ XBT_PUBLIC sg_sem_t sg_sem_init(int initial_value);
 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
 
index 8e3193b..639c15d 100644 (file)
@@ -89,7 +89,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_VM_all(JNIEnv* env, jclass c
   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);
index b8791b0..fc492d5 100644 (file)
@@ -344,7 +344,7 @@ PYBIND11_MODULE(simgrid, m)
       .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.")
index 4d0d80a..4adb631 100644 (file)
@@ -117,7 +117,7 @@ void MSG_process_migrate(sg_actor_t actor, sg_host_t host)
 {
   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);
 }
@@ -499,7 +499,7 @@ void MSG_sem_release(sg_sem_t sem)
 {
   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);
 }
@@ -507,7 +507,7 @@ void MSG_sem_destroy(const_sg_sem_t 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);
 }
index 8c3963a..6813e18 100644 (file)
@@ -137,7 +137,7 @@ VirtualMachine* VirtualMachine::set_pm(simgrid::s4u::Host* pm)
   return this;
 }
 
-VirtualMachine::state VirtualMachine::get_state()
+VirtualMachine::state VirtualMachine::get_state() const
 {
   return kernel::actor::simcall([this]() { return pimpl_vm_->get_state(); });
 }
index f9b4272..5588ce9 100644 (file)
@@ -103,12 +103,12 @@ int Actor::get_refcount() const
 
 // ***** 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_;
@@ -676,7 +676,7 @@ void sg_actor_migrate(sg_actor_t process, sg_host_t host) // XBT_ATTRIB_DEPRECAT
  * @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);
 }
index b4a5ed7..3d8d8c0 100644 (file)
@@ -46,12 +46,12 @@ void Semaphore::release()
   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(); });
 }
@@ -99,7 +99,7 @@ void sg_sem_release(sg_sem_t sem)
   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();
 }
@@ -114,7 +114,7 @@ void sg_sem_destroy(const_sg_sem_t sem)
  * 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();
 }