X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2abf25f94d9a3fd19a5d85637d6758932be8b047..ed5b6e45b9957b00a2c41f01ce9da418da78cecb:/examples/cxx/explicitDestination/Forwarder.cxx diff --git a/examples/cxx/explicitDestination/Forwarder.cxx b/examples/cxx/explicitDestination/Forwarder.cxx index f209d1832e..651533a11b 100644 --- a/examples/cxx/explicitDestination/Forwarder.cxx +++ b/examples/cxx/explicitDestination/Forwarder.cxx @@ -1,60 +1,61 @@ -#include "Forwarder.hpp" -#include "BasicTask.hpp" -#include "FinalizeTask.hpp" - -#include -#include - -#include -using namespace std; - -MSG_IMPLEMENT_DYNAMIC(Forwarder, Process); - - -int Forwarder::main(int argc, char** argv) -{ - cout << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; - - int aliasCount = argc; - - int taskCount = 0; - - Task* taskReceived; - Task* finalizeTask; - BasicTask* basicTask; - - while(true) - { - taskReceived = Task::receive(Host::currentHost().getName()); - - if(taskReceived->isInstanceOf("FinalizeTask")) - { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "All tasks have been dispatched. Let's tell everybody the computation is over." << endl; - - for (int i = 0; i < aliasCount; i++) - { - finalizeTask = new FinalizeTask(); - finalizeTask->send(argv[i]); - } - - delete taskReceived; - - break; - } - - basicTask = reinterpret_cast(taskReceived); - - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received \"" << basicTask->getName() << "\" " << endl; - - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Sending \"" << basicTask->getName() << "\" to \"" << argv[taskCount % aliasCount] << "\"" << endl; - - basicTask->send(argv[taskCount % aliasCount]); - - taskCount++; - } - - - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "I'm done. See you!" << endl; - - return 0; -} \ No newline at end of file +#include "Forwarder.hpp" +#include "BasicTask.hpp" +#include "FinalizeTask.hpp" + +#include +#include + +#include + + +MSG_IMPLEMENT_DYNAMIC(Forwarder, Process) + + +int Forwarder::main(int argc, char** argv) +{ + info("Hello"); + + int aliasCount = argc; + + int taskCount = 0; + + Task* taskReceived; + Task* finalizeTask; + BasicTask* basicTask; + + while(true) + { + taskReceived = Task::receive(Host::currentHost().getName()); + + if(taskReceived->isInstanceOf("FinalizeTask")) + { + info("All tasks have been dispatched. Let's tell everybody the computation is over."); + + for (int i = 0; i < aliasCount; i++) + { + finalizeTask = new FinalizeTask(); + finalizeTask->send(argv[i]); + } + + delete taskReceived; + + break; + } + + basicTask = reinterpret_cast(taskReceived); + + info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); + + info(TEXT_("Sending \"") + TEXT_(basicTask->getName()) + TEXT_("\" to \"") + TEXT_(argv[taskCount % aliasCount]) + TEXT_("\"")); + + basicTask->send(argv[taskCount % aliasCount]); + + taskCount++; + } + + + info("I'm done. See you!"); + + delete this; + return 0; +}