Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[simix] Use std::string for s_smx_process_arg
[simgrid.git] / src / simix / SynchroIo.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/SynchroIo.hpp"
7 #include "src/surf/surf_interface.hpp"
8 #include "src/simix/popping_private.h"
9 #include "src/simix/smx_private.h"
10
11 void simgrid::simix::Io::suspend()
12 {
13   if (surf_io)
14     surf_io->suspend();
15 }
16
17 void simgrid::simix::Io::resume()
18 {
19   if (surf_io)
20     surf_io->resume();
21 }
22
23 void simgrid::simix::Io::post()
24 {
25   xbt_fifo_item_t i;
26   smx_simcall_t simcall;
27
28   xbt_fifo_foreach(simcalls,i,simcall,smx_simcall_t) {
29     switch (simcall->call) {
30     case SIMCALL_FILE_OPEN: {
31       smx_file_t tmp = xbt_new(s_smx_file_t,1);
32       tmp->surf_file = surf_storage_action_get_file(surf_io);
33       simcall_file_open__set__result(simcall, tmp);
34       break;
35     }
36     case SIMCALL_FILE_CLOSE:
37       xbt_free(simcall_file_close__get__fd(simcall));
38       simcall_file_close__set__result(simcall, 0);
39       break;
40     case SIMCALL_FILE_WRITE:
41       simcall_file_write__set__result(simcall, surf_io->getCost());
42       break;
43
44     case SIMCALL_FILE_READ:
45       simcall_file_read__set__result(simcall, surf_io->getCost());
46       break;
47
48     default:
49       break;
50     }
51   }
52
53   switch (surf_io->getState()) {
54
55     case simgrid::surf::Action::State::failed:
56       state = SIMIX_FAILED;
57       break;
58
59     case simgrid::surf::Action::State::done:
60       state = SIMIX_DONE;
61       break;
62
63     default:
64       THROW_IMPOSSIBLE;
65       break;
66   }
67
68   SIMIX_io_finish(this);
69 }