Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix smpi_execute_benched.
[simgrid.git] / examples / java / async / dsend / Main.java
1 /* Copyright (c) 2006-2014, 2016. 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 async.dsend;
8
9 /** This example demonstrates the use of the Task.dsend() method.
10  * 
11  *  This way, the sender can be detached from the communication: it is not blocked as with Task.send() 
12  *  and has nothing to do at the end as with Task.isend() where it must do a Comm.wait().
13  */
14
15 import org.simgrid.msg.Host;
16 import org.simgrid.msg.HostNotFoundException;
17 import org.simgrid.msg.Msg;
18
19 class Main {
20   private Main() {
21         /* This is just to ensure that nobody creates an instance of this singleton */
22     throw new IllegalAccessError("Utility class");
23   }
24
25   public static void main(String[] args) throws HostNotFoundException {
26     Msg.init(args);
27
28     String platform = "../platforms/small_platform.xml";
29     if (args.length >= 1) {
30         platform = args[0]; // Override the default value if passed on the command line
31     }
32
33     /* construct the platform and deploy the application */
34     Msg.createEnvironment(platform);
35     Host[] hosts = Host.all();
36     new Sender(hosts[0],"Sender").start();
37     for (int i=1; i < hosts.length; i++){
38       new Receiver(hosts[i], "Receiver").start();
39     }
40     /*  execute the simulation. */
41     Msg.run();
42   }
43 }