Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill another out of date script
[simgrid.git] / contrib / psg / src / psgsim / PSGTask.java
1 package psgsim;
2
3 import org.simgrid.msg.HostFailureException;
4 import org.simgrid.msg.Task;
5 import org.simgrid.msg.TimeoutException;
6 import org.simgrid.msg.TransferFailureException;
7
8 /**
9  * The PSGTask includes all the parameters of sending a message as the size, the
10  * compute duration and the protocol identifier.
11  * 
12  * @author Khaled Baati 28/10/2014
13  * @version version 1.1
14  */
15 public class PSGTask extends org.simgrid.msg.Task {
16         /** The Message to be sent **/
17         private Object event;
18         /** The protocol identifier **/
19         private int pid;
20
21         /**
22          * Construct a new task to be sent.
23          * 
24          * @param name
25          *            The name of task
26          * @param computeDuration
27          *            The compute duration
28          * 
29          * @param messageSize
30          *            The size of the message
31          * @param event
32          *            The message to be sent
33          * @param pid
34          *            The protocol identifier
35          */
36         public PSGTask(String name, double computeDuration, double messageSize,
37                         Object event, int pid) {
38                 super(name, computeDuration, messageSize);
39                 this.event = event;
40                 this.pid = pid;
41         }
42
43         /**
44          * 
45          * @return the protocol identifier
46          */
47         public int getPid() {
48                 return pid;
49         }
50
51         /**
52          * 
53          * @return the message
54          */
55         public Object getEvent() {
56                 return event;
57         }
58
59         /**
60          * Retrieves next task on the mailbox identified by the specified name (wait
61          * at most timeout seconds)
62          * 
63          * @param mailbox
64          *            the mailbox on where to receive the task
65          * @param timeout
66          *            the timeout to wait for receiving the task
67          * @return the task
68          */
69         public static Task receive(String mailbox, double timeout) {
70                 double time = PSGPlatform.getClock();
71                 if (time + timeout > PSGPlatform.getClock()) {
72                         try {
73                                 return receive(mailbox, timeout, null);
74                         } catch (TimeoutException e) {
75                         } catch (TransferFailureException e) {
76                                 e.printStackTrace();
77                         } catch (HostFailureException e) {
78                                 e.printStackTrace();
79                         }
80                 }
81                 return null;
82
83         }
84
85 }