try {
comm->wait(timeout);
XBT_DEBUG("Received the answer to my 'Predecessor Alive': my predecessor %d is alive", pred_id_);
- delete message;
} catch (xbt_ex& e) {
if (e.category == timeout_error) {
XBT_DEBUG("Failed to receive the answer to my 'Predecessor Alive' request");
pred_id_ = -1;
}
}
+ delete message;
}
/* Asks its predecessor to a remote node
friend void intrusive_ptr_add_ref(Comm * c);
protected:
- Activity();
- virtual ~Activity();
+ Activity() = default;
+ ~Activity() = default;
public:
Activity(Activity const&) = delete;
#include <simgrid/forward.h>
#include <simgrid/s4u/Activity.hpp>
#include <simgrid/s4u/forward.hpp>
-
namespace simgrid {
namespace s4u {
/** @brief Communication async
void ref();
/** @brief Reduces the refcount */
void unref();
-
private:
std::atomic_int_fast32_t refcount_{1};
};
namespace simgrid {
namespace s4u {
-Activity::Activity() {
-
-}
-Activity::~Activity() {
-
-}
-
void Activity::setRemains(double remains) {
xbt_assert(state_ == inited, "Cannot change the remaining amount of work once the Activity is started");
remains_ = remains;
}
}
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;
}
userData_, timeout, rate_);
}
state_ = finished;
+ if (pimpl_)
+ pimpl_->unref();
}
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));
simgrid::kernel::activity::CommImpl* commPimpl = static_cast<simgrid::kernel::activity::CommImpl*>(pimpl_);
commPimpl->cancel();
}
+
bool Comm::test() {
xbt_assert(state_ == inited || state_ == started || state_ == finished);
if(simcall_comm_test(pimpl_)){
state_ = finished;
+ pimpl_->unref();
return true;
}
return false;
other_comm->state = SIMIX_READY;
other_comm->type = SIMIX_COMM_READY;
-
}
src_proc->comms.push_back(other_comm);