1 /* Copyright (c) 2019. 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 #include "DiskImpl.hpp"
8 #include "simgrid/s4u/Engine.hpp"
9 #include "src/kernel/EngineImpl.hpp"
10 #include "src/kernel/lmm/maxmin.hpp"
12 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(disk_kernel, surf, "Logging specific to the disk kernel resource");
14 simgrid::kernel::resource::DiskModel* surf_disk_model = nullptr;
24 DiskModel::DiskModel() : Model(Model::UpdateAlgo::FULL)
26 set_maxmin_system(new simgrid::kernel::lmm::System(true /* selective update */));
29 DiskModel::~DiskModel()
31 surf_disk_model = nullptr;
38 DiskImpl::DiskImpl(kernel::resource::Model* model, const std::string& name, kernel::lmm::System* maxminSystem,
39 double read_bw, double write_bw)
40 : Resource(model, name, maxminSystem->constraint_new(this, std::max(read_bw, write_bw)))
41 // FIXME , piface_(name, this)
44 XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", read_bw, write_bw);
45 constraint_read_ = maxminSystem->constraint_new(this, read_bw);
46 constraint_write_ = maxminSystem->constraint_new(this, write_bw);
51 xbt_assert(currently_destroying_, "Don't delete Disks directly. Call destroy() instead.");
54 /** @brief Fire the required callbacks and destroy the object
56 * Don't delete directly a Disk, call d->destroy() instead.
58 void DiskImpl::destroy()
60 if (not currently_destroying_) {
61 currently_destroying_ = true;
62 // FIXME s4u::Storage::on_destruction(this->piface_);
67 bool DiskImpl::is_used()
72 void DiskImpl::apply_event(kernel::profile::Event* /*event*/, double /*value*/)
77 void DiskImpl::turn_on()
81 // FIXME s4u::Storage::on_state_change(this->piface_);
84 void DiskImpl::turn_off()
88 // FIXME s4u::Storage::on_state_change(this->piface_);
92 xbt::signal<void(DiskAction const&, kernel::resource::Action::State, kernel::resource::Action::State)>
93 DiskAction::on_state_change;
98 void DiskAction::set_state(Action::State state)
100 Action::State old = get_state();
101 Action::set_state(state);
102 on_state_change(*this, old, state);
104 } // namespace resource
105 } // namespace kernel
106 } // namespace simgrid