1 /* Copyright (c) 2017-2018. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef SIMGRID_S4U_IO_HPP
7 #define SIMGRID_S4U_IO_HPP
9 #include <simgrid/forward.h>
10 #include <simgrid/s4u/Activity.hpp>
18 /** I/O Activity, representing the asynchronous disk access.
20 * They are generated from simgrid::s4u::Storage::read() and simgrid::s4u::Storage::write().
23 class XBT_PUBLIC Io : public Activity {
25 enum class OpType { READ, WRITE };
28 explicit Io(sg_size_t size, OpType type) : Activity(), size_(size), type_(type) {}
30 friend XBT_PUBLIC void intrusive_ptr_release(simgrid::s4u::Io* i);
31 friend XBT_PUBLIC void intrusive_ptr_add_ref(simgrid::s4u::Io* i);
32 friend simgrid::s4u::Storage; // Factory of IOs
38 Io* wait_for(double timeout) override;
39 Io* cancel() override;
42 double get_remaining() override;
43 sg_size_t get_performed_ioops();
46 XBT_ATTRIB_DEPRECATED_v324("Please use Io::wait_for()") void wait(double t) override { wait_for(t); }
51 sg_storage_t storage_ = nullptr;
52 std::string name_ = "";
53 OpType type_ = OpType::READ;
54 std::atomic_int_fast32_t refcount_{0};
57 }; // Namespace simgrid::s4u
59 #endif /* SIMGRID_S4U_IO_HPP */