Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
merge SIMIX_synchro_finish into RawImpl::post
[simgrid.git] / src / kernel / activity / SynchroRaw.cpp
1 /* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "src/kernel/activity/SynchroRaw.hpp"
7 #include "simgrid/kernel/resource/Action.hpp"
8 #include "src/kernel/context/Context.hpp"
9 #include "src/simix/smx_synchro_private.hpp"
10 #include "src/surf/surf_interface.hpp"
11
12 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_synchro);
13 namespace simgrid {
14 namespace kernel {
15 namespace activity {
16
17 RawImpl::~RawImpl()
18 {
19   surf_action_->unref();
20 }
21 void RawImpl::suspend()
22 {
23   /* The suspension of raw synchros is delayed to when the process is rescheduled. */
24 }
25
26 void RawImpl::resume()
27 {
28   /* I cannot resume raw synchros directly. This is delayed to when the process is rescheduled at
29    * the end of the synchro. */
30 }
31 void RawImpl::post()
32 {
33   XBT_IN("(%p)",this);
34   smx_simcall_t simcall = simcalls_.front();
35   simcalls_.pop_front();
36
37   SIMIX_synchro_stop_waiting(simcall->issuer, simcall);
38   simcall->issuer->waiting_synchro = nullptr;
39
40   if (surf_action_->get_state() == resource::Action::State::FAILED) {
41     state_ = SIMIX_FAILED;
42     simcall->issuer->context_->iwannadie = true;
43   } else if (surf_action_->get_state() == resource::Action::State::FINISHED) {
44     state_ = SIMIX_SRC_TIMEOUT;
45     SIMIX_simcall_answer(simcall);
46   }
47   XBT_OUT();
48 }
49 } // namespace activity
50 } // namespace kernel
51 } // namespace simgrid