X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7fe20e7abb421590451c0cbaa578adf01ab7b940..aa19b8ec2814d04500c24d5df65a4e620e8e8969:/src/kernel/activity/CommImpl.cpp diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index 85ccbea5c1..129aeafc5e 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -1,13 +1,14 @@ -/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/kernel/activity/CommImpl.hpp" +#include "simgrid/kernel/resource/Action.hpp" #include "simgrid/modelchecker.h" -#include "src/mc/mc_replay.h" -#include "src/simix/smx_network_private.h" +#include "src/mc/mc_replay.hpp" +#include "src/simix/smx_network_private.hpp" #include "src/surf/surf_interface.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_network); @@ -17,7 +18,6 @@ simgrid::kernel::activity::CommImpl::CommImpl(e_smx_comm_type_t _type) : type(_t state = SIMIX_WAITING; src_data = nullptr; dst_data = nullptr; - intrusive_ptr_add_ref(this); XBT_DEBUG("Create comm activity %p", this); } @@ -42,16 +42,16 @@ simgrid::kernel::activity::CommImpl::~CommImpl() void simgrid::kernel::activity::CommImpl::suspend() { /* FIXME: shall we suspend also the timeout synchro? */ - if (surf_comm) - surf_comm->suspend(); + if (surfAction_) + surfAction_->suspend(); /* in the other case, the action will be suspended on creation, in SIMIX_comm_start() */ } void simgrid::kernel::activity::CommImpl::resume() { /*FIXME: check what happen with the timeouts */ - if (surf_comm) - surf_comm->resume(); + if (surfAction_) + surfAction_->resume(); /* in the other case, the synchro were not really suspended yet, see SIMIX_comm_suspend() and SIMIX_comm_start() */ } @@ -62,30 +62,25 @@ void simgrid::kernel::activity::CommImpl::cancel() if (state == SIMIX_WAITING) { mbox->remove(this); state = SIMIX_CANCELED; - this->unref(); } else if (not MC_is_active() /* when running the MC there are no surf actions */ && not MC_record_replay_is_active() && (state == SIMIX_READY || state == SIMIX_RUNNING)) { - surf_comm->cancel(); + surfAction_->cancel(); } } /** @brief get the amount remaining from the communication */ double simgrid::kernel::activity::CommImpl::remains() { - if (state == SIMIX_RUNNING) - return surf_comm->getRemains(); - - /* FIXME: check what should be returned in the other cases */ - return 0; + return surfAction_->get_remains(); } /** @brief This is part of the cleanup process, probably an internal command */ void simgrid::kernel::activity::CommImpl::cleanupSurf() { - if (surf_comm) { - surf_comm->unref(); - surf_comm = nullptr; + if (surfAction_) { + surfAction_->unref(); + surfAction_ = nullptr; } if (src_timeout) { @@ -102,15 +97,15 @@ void simgrid::kernel::activity::CommImpl::cleanupSurf() void simgrid::kernel::activity::CommImpl::post() { /* Update synchro state */ - if (src_timeout && src_timeout->getState() == simgrid::surf::Action::State::done) + if (src_timeout && src_timeout->get_state() == simgrid::kernel::resource::Action::State::done) state = SIMIX_SRC_TIMEOUT; - else if (dst_timeout && dst_timeout->getState() == simgrid::surf::Action::State::done) + else if (dst_timeout && dst_timeout->get_state() == simgrid::kernel::resource::Action::State::done) state = SIMIX_DST_TIMEOUT; - else if (src_timeout && src_timeout->getState() == simgrid::surf::Action::State::failed) + else if (src_timeout && src_timeout->get_state() == simgrid::kernel::resource::Action::State::failed) state = SIMIX_SRC_HOST_FAILURE; - else if (dst_timeout && dst_timeout->getState() == simgrid::surf::Action::State::failed) + else if (dst_timeout && dst_timeout->get_state() == simgrid::kernel::resource::Action::State::failed) state = SIMIX_DST_HOST_FAILURE; - else if (surf_comm && surf_comm->getState() == simgrid::surf::Action::State::failed) { + else if (surfAction_ && surfAction_->get_state() == simgrid::kernel::resource::Action::State::failed) { state = SIMIX_LINK_FAILURE; } else state = SIMIX_DONE; @@ -124,6 +119,5 @@ void simgrid::kernel::activity::CommImpl::post() /* if there are simcalls associated with the synchro, then answer them */ if (not simcalls.empty()) { SIMIX_comm_finish(this); - this->unref(); } }