12 Task::Task(const Task& rTask)
\r
18 throw(NativeException)
\r
20 if(NULL != nativeTask)
\r
22 if(MSG_OK != MSG_task_destroy(nativeTask))
\r
24 // TODO throw NativeException
\r
30 Task::Task(const char* name, double computeDuration, double messageSize)
\r
33 if(computeDuration < 0)
\r
35 // TODO throw exception
\r
39 if(messageSize < 0)
\r
41 // TODO throw exception
\r
47 // TODO throw exception
\r
52 nativeTask = MSG_task_create(name, computeDuration, messageSize, NULL);
\r
54 nativeTask->data = (void*)this;
\r
57 Task::Task(const char* name, Host* hosts, double* computeDurations, double* messageSizes)
\r
59 // TODO parallel task create
\r
63 const char* Task::getName(void) const
\r
65 return nativeTask->name;
\r
68 Process& Task::getSender(void) const
\r
70 m_proccess_t nativeProcess = MSG_task_get_sender(nativeTask);
\r
72 return (*((Process*)(nativeProcess->data)));
\r
75 Host& Task::getSource(void) const
\r
76 throw(NativeException)
\r
78 m_host_t nativeHost = MSG_task_get_source(nativeTask);
\r
80 if(!nativeHost->data)
\r
82 // TODO throw the exception
\r
86 return (*((Host*)(nativeHost->data)));
\r
89 double Task::getComputeDuration(void) const
\r
91 return MSG_task_get_compute_duration(nativeTask);
\r
94 double Task::getRemainingDuration(void) const
\r
96 return MSG_task_get_remaining_computation(nativeTask);
\r
99 void Task::setPriority(double priority)
\r
101 MSG_task_set_priority(nativeTask, priority);
\r
104 Task& Task::get(int channel)
\r
105 throw(NativeException)
\r
107 m_task_t nativeTask = NULL;
\r
110 if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , -1.0, NULL))
\r
112 // TODO throw the NativeException
\r
116 return (*((Task*)(nativeTask->data)));
\r
119 Task& Task::get(int channel, const Host& rHost)
\r
120 throw(NativeException)
\r
122 m_task_t nativeTask = NULL;
\r
125 if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , -1.0, rHost.nativeHost))
\r
127 // TODO throw the NativeException
\r
131 return (*((Task*)(nativeTask->data)));
\r
134 Task& Task::get(int channel, double timeout, const Host& rHost)
\r
135 throw(NativeException)
\r
137 m_task_t nativeTask = NULL;
\r
140 if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , timeout, rHost.nativeHost))
\r
142 // TODO throw the NativeException
\r
146 return (*((Task*)(nativeTask->data)));
\r
149 bool static Task::probe(int channel)
\r
151 return (bool)MSG_task_Iprobe(channel);
\r
154 int Task::probe(int channel, const Host& rHost)
\r
156 return MSG_task_probe_from_host(chan_id,rHost.nativeHost);
\r
159 void Task::execute(void)
\r
160 throw(NativeException)
\r
162 if(MSG_OK != MSG_task_execute(nativeTask))
\r
164 // TODO throw NativeException
\r
168 void Task::cancel(void)
\r
169 throw(NativeException)
\r
171 if(MSG_OK != MSG_task_cancel(nativeTask))
\r
173 // TODO throw NativeException
\r
177 void Task::send(void)
\r
178 throw(NativeException)
\r
182 char* alias = (char*)calloc(strlen(Process::currentProcess().getName() + strlen(Host::currentHost().getName()) + 2);
\r
183 sprintf(alias,"%s:%s", Process::currentProcess().getName(),Host::currentHost().getName());
\r
187 rv = MSG_task_send_with_timeout(nativeTask, alias, -1.0);
\r
193 // TODO throw the NativeException
\r
198 void Task::send(const char* alias)
\r
199 throw(NativeException)
\r
202 if(MSG_OK != MSG_task_send_with_timeout(nativeTask, alias, -1.0))
\r
204 // TODO throw the NativeException
\r
208 void Task::send(double timeout)
\r
209 throw(NativeException)
\r
213 char* alias = (char*)calloc(strlen(Process::currentProcess().getName() + strlen(Host::currentHost().getName()) + 2);
\r
214 sprintf(alias,"%s:%s", Process::currentProcess().getName(),Host::currentHost().getName());
\r
218 rv = MSG_task_send_with_timeout(nativeTask, alias, timeout);
\r
224 // TODO throw the NativeException
\r
228 void Task::send(const char* alias, double timeout)
\r
229 throw(NativeException)
\r
231 if(MSG_OK != MSG_task_send_with_timeout(nativeTask, alias, timeout))
\r
233 // TODO throw the NativeException
\r
237 void Task::sendBounded(double maxRate)
\r
238 throw(NativeException)
\r
242 char* alias = (char*)calloc(strlen(Process::currentProcess().getName() + strlen(Host::currentHost().getName()) + 2);
\r
243 sprintf(alias,"%s:%s", Process::currentProcess().getName(),Host::currentHost().getName());
\r
245 rv = MSG_task_send_bounded(nativeTask, alias, maxRate);
\r
253 // TODO throw the NativeException
\r
257 void Task::sendBounded(const char* alias, double maxRate)
\r
258 throw(NativeException)
\r
260 if(MSG_OK != MSG_task_send_bounded(nativeTask, alias, maxRate))
\r
262 // TODO throw the NativeException
\r
266 Task& Task::receive(void)
\r
267 throw(NativeException)
\r
271 char* alias = (char*)calloc(strlen(Process::currentProcess().getName() + strlen(Host::currentHost().getName()) + 2);
\r
272 sprintf(alias,"%s:%s", Process::currentProcess().getName(),Host::currentHost().getName());
\r
274 m_task_t nativeTask = NULL;
\r
276 rv = MSG_task_receive_ext(&nativeTask, alias, -1.0, NULL);
\r
282 // TODO thow NativeException
\r
286 return (*((Task*)nativeTask->data));
\r
289 Task& Task::receive(const char* alias)
\r
290 throw(NativeException)
\r
292 m_task_t nativeTask = NULL;
\r
294 if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, -1.0, NULL))
\r
296 // TODO thow NativeException
\r
300 return (*((Task*)nativeTask->data));
\r
303 Task& Task::receive(const char* alias, double timeout)
\r
304 throw(NativeException)
\r
306 m_task_t nativeTask = NULL;
\r
308 if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, timeout, NULL))
\r
310 // TODO thow NativeException
\r
314 return (*((Task*)nativeTask->data));
\r
317 Task& Task::receive(const char* alias, const Host& rHost)
\r
318 throw(NativeException)
\r
320 m_task_t nativeTask = NULL;
\r
323 if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, -1.0, rHost.nativeHost))
\r
325 // TODO thow NativeException
\r
329 return (*((Task*)nativeTask->data));
\r
332 Task& Task::receive(const char* alias, double timeout, const Host& rHost)
\r
333 throw(NativeException)
\r
335 m_task_t nativeTask = NULL;
\r
338 if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, timeout, rHost.nativeHost))
\r
340 // TODO thow NativeException
\r
344 return (*((Task*)nativeTask->data));
\r
347 bool Task::listen(void)
\r
348 throw(NativeException)
\r
352 char* alias = (char*)calloc(strlen(Process::currentProcess().getName() + strlen(Host::currentHost().getName()) + 2);
\r
353 sprintf(alias,"%s:%s", Process::currentProcess().getName(),Host::currentHost().getName());
\r
355 rv = MSG_task_listen(alias);
\r
362 bool Task::listen(const char* alias)
\r
363 throw(NativeException)
\r
365 return (bool)MSG_task_listen(alias);
\r
368 bool Task::listenFrom(void)
\r
369 throw(NativeException)
\r
373 char* alias = (char*)calloc(strlen(Process::currentProcess().getName() + strlen(Host::currentHost().getName()) + 2);
\r
374 sprintf(alias,"%s:%s", Process::currentProcess().getName(),Host::currentHost().getName());
\r
376 rv = MSG_task_listen_from(alias);
\r
383 bool Task::listenFrom(const char* alias)
\r
384 throw(NativeException)
\r
386 return (bool)MSG_task_listen_from(alias);
\r
390 bool Task::listenFromHost(const Host& rHost)
\r
391 throw(NativeException)
\r
395 char* alias = (char*)calloc(strlen(Process::currentProcess().getName() + strlen(Host::currentHost().getName()) + 2);
\r
396 sprintf(alias,"%s:%s", Process::currentProcess().getName(),Host::currentHost().getName());
\r
398 rv = MSG_task_listen_from_host(alias, rHost.nativeHost);
\r
405 bool Task::listenFromHost(const char* alias, const Host& rHost)
\r
406 throw(NativeException)
\r
408 return (bool)MSG_task_listen_from_host(alias, rHost.nativeHost);
\r