A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix host name issue with ns3 wifi, add ssid, set active probing to false
[simgrid.git]
/
src
/
s4u
/
s4u_Mailbox.cpp
diff --git
a/src/s4u/s4u_Mailbox.cpp
b/src/s4u/s4u_Mailbox.cpp
index d153c08080045822c4e6482c4ed63a7b02984363..72facec07309aa7802834ab6bb0c689b72ba2dd4 100644
(file)
--- a/
src/s4u/s4u_Mailbox.cpp
+++ b/
src/s4u/s4u_Mailbox.cpp
@@
-34,17
+34,26
@@
Mailbox* Mailbox::by_name(const std::string& name)
return &mbox->piface_;
}
return &mbox->piface_;
}
-bool Mailbox::empty()
+bool Mailbox::empty()
const
{
return pimpl_->comm_queue_.empty();
}
{
return pimpl_->comm_queue_.empty();
}
-bool Mailbox::listen()
+bool Mailbox::listen()
const
{
return not this->empty() || (pimpl_->permanent_receiver_ && not pimpl_->done_comm_queue_.empty());
}
{
return not this->empty() || (pimpl_->permanent_receiver_ && not pimpl_->done_comm_queue_.empty());
}
-bool Mailbox::ready()
+aid_t Mailbox::listen_from() const
+{
+ kernel::activity::CommImplPtr comm = front();
+ if (comm && comm->src_actor_)
+ return comm->src_actor_->get_pid();
+ else
+ return -1;
+}
+
+bool Mailbox::ready() const
{
bool comm_ready = false;
if (not pimpl_->comm_queue_.empty()) {
{
bool comm_ready = false;
if (not pimpl_->comm_queue_.empty()) {
@@
-56,7
+65,7
@@
bool Mailbox::ready()
return comm_ready;
}
return comm_ready;
}
-kernel::activity::CommImplPtr Mailbox::front()
+kernel::activity::CommImplPtr Mailbox::front()
const
{
return pimpl_->comm_queue_.empty() ? nullptr : pimpl_->comm_queue_.front();
}
{
return pimpl_->comm_queue_.empty() ? nullptr : pimpl_->comm_queue_.front();
}
@@
-67,7
+76,7
@@
void Mailbox::set_receiver(ActorPtr actor)
}
/** @brief get the receiver (process associated to the mailbox) */
}
/** @brief get the receiver (process associated to the mailbox) */
-ActorPtr Mailbox::get_receiver()
+ActorPtr Mailbox::get_receiver()
const
{
if (pimpl_->permanent_receiver_ == nullptr)
return ActorPtr();
{
if (pimpl_->permanent_receiver_ == nullptr)
return ActorPtr();
@@
-153,7
+162,8
@@
void* Mailbox::get(double timeout)
return res;
}
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); });
}
{
return kernel::actor::simcall([this, type, match_fun, data] { return pimpl_->iprobe(type, match_fun, data); });
}
@@
-166,7
+176,7
@@
sg_mailbox_t sg_mailbox_by_name(const char* alias)
return simgrid::s4u::Mailbox::by_name(alias);
}
return simgrid::s4u::Mailbox::by_name(alias);
}
-const char* sg_mailbox_get_name(sg_mailbox_t mailbox)
+const char* sg_mailbox_get_name(
const_
sg_mailbox_t mailbox)
{
return mailbox->get_cname();
}
{
return mailbox->get_cname();
}
@@
-200,9
+210,16
@@
void* sg_mailbox_get(sg_mailbox_t mailbox)
return mailbox->get();
}
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)
{
void sg_mailbox_put(sg_mailbox_t mailbox, void* payload, long simulated_size_in_bytes)
{
-
return
mailbox->put(payload, 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)
}
sg_comm_t sg_mailbox_put_async(sg_mailbox_t mailbox, void* payload, long simulated_size_in_bytes)
@@
-211,3
+228,10
@@
sg_comm_t sg_mailbox_put_async(sg_mailbox_t mailbox, void* payload, long simulat
comm->add_ref();
return comm.get();
}
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();
+}