Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into CRTP
[simgrid.git] / src / kernel / resource / Resource.cpp
1 /* Copyright (c) 2004-2019. 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 "simgrid/kernel/resource/Resource.hpp"
7 #include "src/kernel/lmm/maxmin.hpp" // Constraint
8 #include "src/kernel/resource/profile/FutureEvtSet.hpp"
9 #include "src/kernel/resource/profile/Profile.hpp"
10 #include "src/surf/surf_interface.hpp"
11
12 namespace simgrid {
13 namespace kernel {
14 namespace resource {
15
16 Resource::~Resource() = default;
17
18 double Resource::get_load() const
19 {
20   return constraint_->get_usage();
21 }
22
23 void Resource::set_state_profile(profile::Profile* profile)
24 {
25   xbt_assert(state_event_ == nullptr, "Cannot set a second state profile to %s", get_cname());
26   state_event_ = profile->schedule(&profile::future_evt_set, this);
27 }
28
29 } // namespace resource
30 } // namespace kernel
31 } // namespace simgrid