Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use only the C++ dtor for Synchro::Raw
[simgrid.git] / src / simix / SynchroExec.cpp
1 /* Copyright (c) 2007-2016. 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/simix/SynchroExec.hpp"
7 #include "src/surf/surf_interface.hpp"
8 #include "src/simix/smx_host_private.h"
9
10 simgrid::simix::Exec::~Exec()
11 {
12   if (surf_exec)
13     surf_exec->unref();
14 }
15 void simgrid::simix::Exec::suspend()
16 {
17   if (surf_exec)
18     surf_exec->suspend();
19 }
20
21 void simgrid::simix::Exec::resume()
22 {
23   if (surf_exec)
24     surf_exec->resume();
25 }
26
27 double simgrid::simix::Exec::remains()
28 {
29   if (state == SIMIX_RUNNING)
30     return surf_exec->getRemains();
31
32   return 0;
33 }
34
35 void simgrid::simix::Exec::post()
36 {
37   if (host && host->isOff()) {/* FIMXE: handle resource failure for parallel tasks too */
38     /* If the host running the synchro failed, notice it. This way, the asking
39      * process can be killed if it runs on that host itself */
40     state = SIMIX_FAILED;
41   } else if (surf_exec->getState() == simgrid::surf::Action::State::failed) {
42     /* If the host running the synchro didn't fail, then the synchro was canceled */
43     state = SIMIX_CANCELED;
44   } else {
45     state = SIMIX_DONE;
46   }
47
48   if (surf_exec) {
49     surf_exec->unref();
50     surf_exec = NULL;
51   }
52
53   /* If there are simcalls associated with the synchro, then answer them */
54   if (xbt_fifo_size(simcalls))
55     SIMIX_execution_finish(this);
56 }