XBT_PUBLIC_CLASS Host :
public simgrid::xbt::Extendable<Host> {
+
+ public:
+ surf::Cpu *p_cpu;
+
private:
simgrid::xbt::string name_;
public:
SD_HOST_LEVEL = simgrid::Host::extension_create(__SD_workstation_destroy);
SIMIX_HOST_LEVEL = simgrid::Host::extension_create(SIMIX_host_destroy);
USER_HOST_LEVEL = simgrid::Host::extension_create(NULL);
- simgrid::surf::Cpu::classInit();
}
// ========== User data Layer ==========
// ========== SURF CPU ============
surf_cpu_t sg_host_surfcpu(sg_host_t host) {
- return host->extension<simgrid::surf::Cpu>();
+ return host->p_cpu;
}
void sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu) {
- host->extension_set(simgrid::surf::Cpu::EXTENSION_ID, cpu); // FIXME: use the typesafe version
+ host->p_cpu = cpu;
}
void sg_host_surfcpu_destroy(sg_host_t host) {
- host->extension_set<simgrid::surf::Cpu>(nullptr);
+ host->p_cpu = nullptr;
}
// ========== RoutingEdge ============
surf_RoutingEdge *sg_host_edge(sg_host_t host) {
namespace simgrid {
namespace surf {
-simgrid::xbt::Extension<simgrid::Host, Cpu> Cpu::EXTENSION_ID;
-
-void Cpu::classInit()
-{
- if (!EXTENSION_ID.valid())
- EXTENSION_ID = simgrid::Host::extension_create<simgrid::surf::Cpu>();
-}
-
/*************
* Callbacks *
*************/
, m_speedScale(speedScale)
, m_host(host)
{
- host->extension_set(Cpu::EXTENSION_ID, this);
+ host->p_cpu = this;
// Copy the power peak array:
p_speedPeakList = xbt_dynar_new(sizeof(double), nullptr);
, m_speedScale(speedScale)
, m_host(host)
{
- host->extension_set(Cpu::EXTENSION_ID, this);
+ host->p_cpu = this;
// Copy the power peak array:
p_speedPeakList = xbt_dynar_new(sizeof(double), nullptr);
*/
XBT_PUBLIC_CLASS Cpu : public simgrid::surf::Resource {
public:
- static simgrid::xbt::Extension<simgrid::Host, Cpu> EXTENSION_ID;
- static void classInit();
Cpu();
/**
}
surf_action_t surf_host_sleep(sg_host_t host, double duration){
- return host->extension(simgrid::surf::Cpu::EXTENSION_ID)->sleep(duration);
+ return host->p_cpu->sleep(duration);
}
xbt_dict_t sg_host_get_properties(sg_host_t host) {
}
surf_action_t surf_host_execute(sg_host_t host, double size){
- return host->extension(simgrid::surf::Cpu::EXTENSION_ID)->execute(size);
+ return host->p_cpu->execute(size);
}
double surf_host_get_current_power_peak(sg_host_t host){
return sg_host_surfcpu(cpu)->execute(size);
}
-surf_action_t surf_cpu_sleep(sg_host_t cpu, double duration){
- return sg_host_surfcpu(cpu)->sleep(duration);
+surf_action_t surf_cpu_sleep(sg_host_t host, double duration){
+ return sg_host_surfcpu(host)->sleep(duration);
}
double surf_action_get_start_time(surf_action_t action){