Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
try to please clang
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 3 Aug 2018 22:48:53 +0000 (00:48 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 3 Aug 2018 22:48:53 +0000 (00:48 +0200)
include/simgrid/s4u/Io.hpp
include/simgrid/s4u/Storage.hpp
src/s4u/s4u_Io.cpp
src/s4u/s4u_Storage.cpp

index 6052171..360dd4f 100644 (file)
@@ -15,13 +15,16 @@ namespace simgrid {
 namespace s4u {
 
 class XBT_PUBLIC Io : public Activity {
-  explicit Io(sg_size_t size) : Activity(), size_(size) {}
+public:
+  enum class OpType { READ, WRITE };
+
+private:
+  explicit Io(sg_size_t size, OpType type) : Activity(), size_(size), type_(type) {}
 public:
   friend XBT_PUBLIC void intrusive_ptr_release(simgrid::s4u::Io* i);
   friend XBT_PUBLIC void intrusive_ptr_add_ref(simgrid::s4u::Io* i);
   friend Storage; // Factory of IOs
 
-  enum class OpType { READ, WRITE };
   ~Io() = default;
 
   Activity* start() override;
@@ -31,7 +34,6 @@ public:
 
   double get_remaining() override;
   sg_size_t get_performed_ioops();
-  IoPtr set_io_type(OpType type);
 
 private:
   sg_size_t size_       = 0;
index 1b1bb5d..956a664 100644 (file)
@@ -7,6 +7,7 @@
 #define INCLUDE_SIMGRID_S4U_STORAGE_HPP_
 
 #include <simgrid/forward.h>
+#include <simgrid/s4u/Io.hpp>
 #include <xbt/Extendable.hpp>
 #include <xbt/base.h>
 #include <xbt/signal.hpp>
@@ -62,7 +63,7 @@ public:
   void set_data(void* data) { userdata_ = data; }
   void* get_data() { return userdata_; }
 
-  IoPtr io_init(sg_size_t size);
+  IoPtr io_init(sg_size_t size, s4u::Io::OpType type);
 
   sg_size_t read(sg_size_t size);
   sg_size_t write(sg_size_t size);
index 88d78a7..65421f4 100644 (file)
@@ -8,6 +8,7 @@
 #include "src/kernel/activity/IoImpl.hpp"
 #include "src/simix/smx_io_private.hpp"
 #include "xbt/log.h"
+#include <string>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_io, s4u_activity, "S4U asynchronous IOs");
 
@@ -16,8 +17,10 @@ namespace s4u {
 
 Activity* Io::start()
 {
-  set_remaining(size_);
-  pimpl_ = simix::simcall([this] { return SIMIX_io_start(name_, size_, storage_, type_); });
+  Activity::set_remaining(size_);
+  pimpl_ = simix::simcall([this] {
+    return boost::static_pointer_cast<kernel::activity::IoImpl>(SIMIX_io_start(name_, size_, storage_, type_));
+  });
   state_ = State::STARTED;
   return this;
 }
@@ -55,13 +58,6 @@ sg_size_t Io::get_performed_ioops()
       [this]() { return boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->get_performed_ioops(); });
 }
 
-IoPtr Io::set_io_type(OpType type)
-{
-  xbt_assert(state_ == State::INITED, "Cannot change the name of an exec after its start");
-  type_ = type;
-  return this;
-}
-
 void intrusive_ptr_release(simgrid::s4u::Io* i)
 {
   if (i->refcount_.fetch_sub(1, std::memory_order_release) == 1) {
index d1b2aa5..aba158e 100644 (file)
@@ -56,25 +56,23 @@ void Storage::set_property(std::string key, std::string value)
   simgrid::simix::simcall([this, key, value] { this->pimpl_->set_property(key, value); });
 }
 
-IoPtr Storage::io_init(sg_size_t size)
+IoPtr Storage::io_init(sg_size_t size, Io::OpType type)
 {
-  IoPtr res     = IoPtr(new Io(size));
+  IoPtr res     = IoPtr(new Io(size, type));
   res->storage_ = this;
   return res;
 }
 
 sg_size_t Storage::read(sg_size_t size)
 {
-  IoPtr i = io_init(size);
-  i->set_io_type(Io::OpType::READ);
+  IoPtr i = io_init(size, Io::OpType::READ);
   i->start()->wait();
   return i->get_performed_ioops();
 }
 
 sg_size_t Storage::write(sg_size_t size)
 {
-  IoPtr i = io_init(size);
-  i->set_io_type(Io::OpType::WRITE);
+  IoPtr i = io_init(size, Io::OpType::WRITE);
   i->start()->wait();
   return i->get_performed_ioops();
 }