Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
reimplement energy plugin using Host callbacks (not Cpu ones)
[simgrid.git] / src / surf / plugins / energy.hpp
index ab9d1f3..a50a6f6 100644 (file)
@@ -6,20 +6,20 @@
 
 #include <xbt/base.h>
 
-#include "../cpu_interface.hpp"
+#include "../host_interface.hpp"
 #include <map>
 
-#ifndef CALLBACK_HPP_
-#define CALLBACK_HPP_
+#ifndef ENERGY_CALLBACK_HPP_
+#define ENERGY_CALLBACK_HPP_
 
-class XBT_PRIVATE CpuEnergy;
+class XBT_PRIVATE HostEnergy;
 
-extern XBT_PRIVATE std::map<Cpu*, CpuEnergy*> *surf_energy;
+extern XBT_PRIVATE std::map<Host*, HostEnergy*> *surf_energy;
 
-class CpuEnergy {
+class HostEnergy {
 public:
-  CpuEnergy(Cpu *ptr);
-  ~CpuEnergy();
+  HostEnergy(Host *ptr);
+  ~HostEnergy();
 
   double getCurrentWattsValue(double cpu_load);
   double getConsumedEnergy();
@@ -31,7 +31,11 @@ public:
   double watts_off;                      /*< Consumption when the machine is turned off (shutdown) */
   double total_energy;                                 /*< Total energy consumed by the host */
   double last_updated;                                 /*< Timestamp of the last energy update event*/
-  Cpu *cpu;
+  Host *host;
+
+  void unref() {if (--refcount == 0) delete this;}
+  void ref() {refcount++;}
+  int refcount = 1;
 };
 
-#endif /* CALLBACK_HPP_ */
+#endif /* ENERGY_CALLBACK_HPP_ */