Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Prepare the deprecation of untyped Mailbox::get functions.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 17 Dec 2020 10:03:25 +0000 (11:03 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 17 Dec 2020 11:46:09 +0000 (12:46 +0100)
include/simgrid/s4u/Mailbox.hpp
src/s4u/s4u_Mailbox.cpp

index 7d5f34d..79a9c15 100644 (file)
@@ -95,16 +95,33 @@ public:
   CommPtr get_init();
   /** Creates and start an async data reception to that mailbox */
   CommPtr get_async(void** data);
-  template <typename T> CommPtr get_async(T** data) { return get_async(reinterpret_cast<void**>(data)); }
+  template <typename T> CommPtr get_async(T** data) { return get_async<void>(reinterpret_cast<void**>(data)); }
 
   /** Blocking data reception */
   void* get();
-  template <typename T> T* get() { return static_cast<T*>(get()); }
+  template <typename T> T* get() { return static_cast<T*>(get<void>()); }
   /** Blocking data reception with timeout */
   void* get(double timeout);
-  template <typename T> T* get(double timeout) { return static_cast<T*>(get(timeout)); }
+  template <typename T> T* get(double timeout) { return static_cast<T*>(get<void>(timeout)); }
 };
 
+template <> CommPtr Mailbox::get_async<void>(void** data);
+template <> void* Mailbox::get<void>();
+template <> void* Mailbox::get<void>(double timeout);
+
+inline CommPtr Mailbox::get_async(void** data)
+{
+  return get_async<void>(data);
+}
+inline void* Mailbox::get()
+{
+  return get<void>();
+}
+inline void* Mailbox::get(double timeout)
+{
+  return get<void>(timeout);
+}
+
 } // namespace s4u
 } // namespace simgrid
 
index 9739967..83b8d72 100644 (file)
@@ -138,7 +138,7 @@ CommPtr Mailbox::get_init()
   return res;
 }
 
-CommPtr Mailbox::get_async(void** data)
+template <> CommPtr Mailbox::get_async<void>(void** data)
 {
   CommPtr res = get_init();
   res->set_dst_data(data, sizeof(*data));
@@ -146,7 +146,7 @@ CommPtr Mailbox::get_async(void** data)
   return res;
 }
 
-void* Mailbox::get()
+template <> void* Mailbox::get<void>()
 {
   void* res = nullptr;
   CommPtr c = get_init();
@@ -155,7 +155,8 @@ void* Mailbox::get()
   c->wait();
   return res;
 }
-void* Mailbox::get(double timeout)
+
+template <> void* Mailbox::get<void>(double timeout)
 {
   void* res = nullptr;
   CommPtr c = get_init();
@@ -210,12 +211,12 @@ int sg_mailbox_listen(const char* alias)
 
 void* sg_mailbox_get(sg_mailbox_t mailbox)
 {
-  return mailbox->get();
+  return mailbox->get<void>();
 }
 
 sg_comm_t sg_mailbox_get_async(sg_mailbox_t mailbox, void** data)
 {
-  auto comm = mailbox->get_async(data);
+  auto comm = mailbox->get_async<void>(data);
   comm->add_ref();
   return comm.get();
 }