X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7fe20e7abb421590451c0cbaa578adf01ab7b940..d68a0ac239494f0a1c7f21b7c195f453ee7a31eb:/src/s4u/s4u_comm.cpp diff --git a/src/s4u/s4u_comm.cpp b/src/s4u/s4u_comm.cpp index d8c635be1a..8340bd320b 100644 --- a/src/s4u/s4u_comm.cpp +++ b/src/s4u/s4u_comm.cpp @@ -117,13 +117,17 @@ void Comm::wait() { } } state_ = finished; + if (pimpl_) + pimpl_->unref(); } + void Comm::wait(double timeout) { xbt_assert(state_ == started || state_ == inited); if (state_ == started) { simcall_comm_wait(pimpl_, timeout); state_ = finished; + pimpl_->unref(); return; } @@ -139,6 +143,8 @@ void Comm::wait(double timeout) { userData_, timeout, rate_); } state_ = finished; + if (pimpl_) + pimpl_->unref(); } void Comm::send_detached(MailboxPtr dest, void* data, int simulatedSize) @@ -150,6 +156,7 @@ void Comm::send_detached(MailboxPtr dest, void* data, int simulatedSize) res->detached_ = true; res->start(); } + s4u::CommPtr Comm::send_async(MailboxPtr dest, void* data, int simulatedSize) { s4u::CommPtr res = CommPtr(s4u::Comm::send_init(dest)); @@ -170,21 +177,24 @@ s4u::CommPtr Comm::recv_async(MailboxPtr dest, void** data) void Comm::cancel() { - simgrid::kernel::activity::CommImpl* commPimpl = static_cast(pimpl_); + simgrid::kernel::activity::CommImplPtr commPimpl = + boost::static_pointer_cast(pimpl_); commPimpl->cancel(); } + bool Comm::test() { xbt_assert(state_ == inited || state_ == started || state_ == finished); - - if (state_ == finished) + + if (state_ == finished) xbt_die("Don't call test on a finished comm."); - + if (state_ == inited) { this->start(); } - + if(simcall_comm_test(pimpl_)){ state_ = finished; + pimpl_->unref(); return true; } return false;