Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / kernel / activity / SynchroIo.cpp
1 /* Copyright (c) 2007-2017. 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/SynchroIo.hpp"
7 #include "src/simix/smx_private.hpp"
8 #include "src/surf/surf_interface.hpp"
9
10 void simgrid::kernel::activity::IoImpl::suspend()
11 {
12   if (surf_io)
13     surf_io->suspend();
14 }
15
16 void simgrid::kernel::activity::IoImpl::resume()
17 {
18   if (surf_io)
19     surf_io->resume();
20 }
21
22 void simgrid::kernel::activity::IoImpl::post()
23 {
24   for (smx_simcall_t const& simcall : simcalls) {
25     switch (simcall->call) {
26     case SIMCALL_FILE_WRITE:
27       simcall_file_write__set__result(simcall, surf_io->getCost());
28       break;
29     case SIMCALL_FILE_READ:
30       simcall_file_read__set__result(simcall, surf_io->getCost());
31       break;
32     default:
33       break;
34     }
35   }
36
37   switch (surf_io->getState()) {
38     case simgrid::surf::Action::State::failed:
39       state = SIMIX_FAILED;
40       break;
41     case simgrid::surf::Action::State::done:
42       state = SIMIX_DONE;
43       break;
44     default:
45       THROW_IMPOSSIBLE;
46       break;
47   }
48
49   SIMIX_io_finish(this);
50 }