Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Energy, onHostDestruction: ensured ptr existence
[simgrid.git] / examples / java / energy / EnergyConsumer.java
1 /* Copyright (c) 2006-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 package energy;
8
9 import org.simgrid.msg.Comm;
10 import org.simgrid.msg.Host;
11 import org.simgrid.msg.Msg;
12 import org.simgrid.msg.MsgException;
13 import org.simgrid.msg.Process;
14 import org.simgrid.msg.Task;
15 import org.simgrid.msg.TimeoutException;
16
17 public class EnergyConsumer extends Process {
18         public EnergyConsumer(Host host, String name, String[] args) {
19                 super(host,name,args);
20         }
21         @Override
22         public void main(String[] args) throws MsgException {
23            Msg.info("Currently consumed energy: "+getHost().getConsumedEnergy());
24            this.waitFor(10);
25            Msg.info("Currently consumed energy after sleeping 10 sec: "+getHost().getConsumedEnergy());
26            new Task(null, 1E9, 0).execute();
27            Msg.info("Currently consumed energy after executing 1E9 flops: "+getHost().getConsumedEnergy());        
28         }
29 }