Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Typo fix
[simgrid.git] / src / s4u / s4u_Mailbox.cpp
index 810fd7f..abbf92e 100644 (file)
@@ -44,6 +44,15 @@ bool Mailbox::listen()
   return not this->empty() || (pimpl_->permanent_receiver_ && not pimpl_->done_comm_queue_.empty());
 }
 
+aid_t Mailbox::listen_from()
+{
+  kernel::activity::CommImplPtr comm = front();
+  if (comm && comm->src_actor_)
+    return comm->src_actor_->get_pid();
+  else
+    return -1;
+}
+
 bool Mailbox::ready()
 {
   bool comm_ready = false;
@@ -153,7 +162,8 @@ void* Mailbox::get(double timeout)
   return res;
 }
 
-smx_activity_t Mailbox::iprobe(int type, bool (*match_fun)(void*, void*, kernel::activity::CommImpl*), void* data)
+kernel::activity::ActivityImplPtr
+Mailbox::iprobe(int type, bool (*match_fun)(void*, void*, kernel::activity::CommImpl*), void* data)
 {
   return kernel::actor::simcall([this, type, match_fun, data] { return pimpl_->iprobe(type, match_fun, data); });
 }
@@ -161,6 +171,16 @@ smx_activity_t Mailbox::iprobe(int type, bool (*match_fun)(void*, void*, kernel:
 } // namespace simgrid
 
 /* **************************** Public C interface *************************** */
+sg_mailbox_t sg_mailbox_by_name(const char* alias)
+{
+  return simgrid::s4u::Mailbox::by_name(alias);
+}
+
+const char* sg_mailbox_get_name(const_sg_mailbox_t mailbox)
+{
+  return mailbox->get_cname();
+}
+
 /** @brief Set the mailbox to receive in asynchronous mode
  *
  * All messages sent to this mailbox will be transferred to the receiver without waiting for the receive call.
@@ -184,3 +204,34 @@ int sg_mailbox_listen(const char* alias)
 {
   return simgrid::s4u::Mailbox::by_name(alias)->listen() ? 1 : 0;
 }
+
+void* sg_mailbox_get(sg_mailbox_t mailbox)
+{
+  return mailbox->get();
+}
+
+sg_comm_t sg_mailbox_get_async(sg_mailbox_t mailbox, void** data)
+{
+  auto comm = mailbox->get_async(data);
+  comm->add_ref();
+  return comm.get();
+}
+
+void sg_mailbox_put(sg_mailbox_t mailbox, void* payload, long simulated_size_in_bytes)
+{
+  mailbox->put(payload, simulated_size_in_bytes);
+}
+
+sg_comm_t sg_mailbox_put_async(sg_mailbox_t mailbox, void* payload, long simulated_size_in_bytes)
+{
+  auto comm = mailbox->put_async(payload, simulated_size_in_bytes);
+  comm->add_ref();
+  return comm.get();
+}
+
+sg_comm_t sg_mailbox_put_init(sg_mailbox_t mailbox, void* payload, long simulated_size_in_bytes)
+{
+  auto comm = mailbox->put_init(payload, simulated_size_in_bytes);
+  comm->add_ref();
+  return comm.get();
+}