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
Use typed Mailbox::get<>() instead of using static_cast everywhere.
[simgrid.git]
/
src
/
s4u
/
s4u_Mailbox.cpp
diff --git
a/src/s4u/s4u_Mailbox.cpp
b/src/s4u/s4u_Mailbox.cpp
index
abbf92e
..
83b8d72
100644
(file)
--- a/
src/s4u/s4u_Mailbox.cpp
+++ b/
src/s4u/s4u_Mailbox.cpp
@@
-34,17
+34,17
@@
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());
}
-aid_t Mailbox::listen_from()
+aid_t Mailbox::listen_from()
const
{
kernel::activity::CommImplPtr comm = front();
if (comm && comm->src_actor_)
{
kernel::activity::CommImplPtr comm = front();
if (comm && comm->src_actor_)
@@
-53,7
+53,7
@@
aid_t Mailbox::listen_from()
return -1;
}
return -1;
}
-bool Mailbox::ready()
+bool Mailbox::ready()
const
{
bool comm_ready = false;
if (not pimpl_->comm_queue_.empty()) {
{
bool comm_ready = false;
if (not pimpl_->comm_queue_.empty()) {
@@
-65,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();
}
@@
-76,33
+76,35
@@
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();
- return pimpl_->permanent_receiver_->iface();
+ return pimpl_->permanent_receiver_->
get_
iface();
}
CommPtr Mailbox::put_init()
{
}
CommPtr Mailbox::put_init()
{
- CommPtr res
= CommPtr(new s4u::
Comm());
+ CommPtr res
(new
Comm());
res->sender_ = kernel::actor::ActorImpl::self();
res->mailbox_ = this;
return res;
}
res->sender_ = kernel::actor::ActorImpl::self();
res->mailbox_ = this;
return res;
}
-s4u::CommPtr Mailbox::put_init(void* data, uint64_t simulated_size_in_bytes)
+
+CommPtr Mailbox::put_init(void* data, uint64_t simulated_size_in_bytes)
{
{
-
s4u::
CommPtr res = put_init();
+ CommPtr res = put_init();
res->set_remaining(simulated_size_in_bytes);
res->src_buff_ = data;
res->src_buff_size_ = sizeof(void*);
return res;
}
res->set_remaining(simulated_size_in_bytes);
res->src_buff_ = data;
res->src_buff_size_ = sizeof(void*);
return res;
}
-s4u::CommPtr Mailbox::put_async(void* payload, uint64_t simulated_size_in_bytes)
+
+CommPtr Mailbox::put_async(void* payload, uint64_t simulated_size_in_bytes)
{
xbt_assert(payload != nullptr, "You cannot send nullptr");
{
xbt_assert(payload != nullptr, "You cannot send nullptr");
-
s4u::
CommPtr res = put_init(payload, simulated_size_in_bytes);
+ CommPtr res = put_init(payload, simulated_size_in_bytes);
res->vetoable_start();
return res;
}
res->vetoable_start();
return res;
}
@@
-128,22
+130,23
@@
void Mailbox::put(void* payload, uint64_t simulated_size_in_bytes, double timeou
c->wait_for(timeout);
}
c->wait_for(timeout);
}
-
s4u::
CommPtr Mailbox::get_init()
+CommPtr Mailbox::get_init()
{
{
- CommPtr res
= CommPtr(new s4u::
Comm());
+ CommPtr res
(new
Comm());
res->receiver_ = kernel::actor::ActorImpl::self();
res->mailbox_ = this;
return res;
}
res->receiver_ = kernel::actor::ActorImpl::self();
res->mailbox_ = this;
return res;
}
-s4u::CommPtr Mailbox::get_async(void** data)
+
+template <> CommPtr Mailbox::get_async<void>(void** data)
{
{
-
s4u::
CommPtr res = get_init();
+ CommPtr res = get_init();
res->set_dst_data(data, sizeof(*data));
res->vetoable_start();
return res;
}
res->set_dst_data(data, sizeof(*data));
res->vetoable_start();
return res;
}
-
void* Mailbox::get
()
+
template <> void* Mailbox::get<void>
()
{
void* res = nullptr;
CommPtr c = get_init();
{
void* res = nullptr;
CommPtr c = get_init();
@@
-152,7
+155,8
@@
void* Mailbox::get()
c->wait();
return res;
}
c->wait();
return res;
}
-void* Mailbox::get(double timeout)
+
+template <> void* Mailbox::get<void>(double timeout)
{
void* res = nullptr;
CommPtr c = get_init();
{
void* res = nullptr;
CommPtr c = get_init();
@@
-207,12
+211,12
@@
int sg_mailbox_listen(const char* alias)
void* sg_mailbox_get(sg_mailbox_t mailbox)
{
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)
{
}
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();
}
comm->add_ref();
return comm.get();
}