From: cherierm Date: Tue, 8 Jul 2008 08:53:23 +0000 (+0000) Subject: delete the process at the end of the main method X-Git-Tag: v3.3~249 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/45fc9b393d412fb043fadf8e660fa6a137125f45?ds=sidebyside delete the process at the end of the main method git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5858 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/examples/cxx/autoDestination/Forwarder.cxx b/examples/cxx/autoDestination/Forwarder.cxx index 07a1a3af9d..24e23728a5 100644 --- a/examples/cxx/autoDestination/Forwarder.cxx +++ b/examples/cxx/autoDestination/Forwarder.cxx @@ -55,6 +55,8 @@ int Forwarder::main(int argc, char** argv) cout <<"[" << getName() << ":" << getHost().getName() << "] " << "I'm done. See you!" << endl; + + delete this; return 0; } \ No newline at end of file diff --git a/examples/cxx/autoDestination/Master.cxx b/examples/cxx/autoDestination/Master.cxx index d3b11e8fbb..9a2d9151f1 100644 --- a/examples/cxx/autoDestination/Master.cxx +++ b/examples/cxx/autoDestination/Master.cxx @@ -24,16 +24,13 @@ int Master::main(int argc, char** argv) cout << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "argc=" << argc << endl; for (int i = 0; i< argc; i++) cout << "argv:" << argv[i] << endl; sscanf(argv[0],"%d", &taskCount); - sscanf(argv[1],"%lg", &taskComputeSize); - sscanf(argv[2],"%lg", &taskCommunicateSize); BasicTaskPtr* basicTasks = new BasicTaskPtr[taskCount]; @@ -46,7 +43,6 @@ int Master::main(int argc, char** argv) } int aliasCount = argc - 3; - char** aliases = (char**) calloc(aliasCount, sizeof(char*)); @@ -89,5 +85,7 @@ int Master::main(int argc, char** argv) delete[] basicTasks; delete[] aliases; + delete this; + return 0; } \ No newline at end of file diff --git a/examples/cxx/autoDestination/Slave.cxx b/examples/cxx/autoDestination/Slave.cxx index a00ecf4c03..8df47121c1 100644 --- a/examples/cxx/autoDestination/Slave.cxx +++ b/examples/cxx/autoDestination/Slave.cxx @@ -12,9 +12,8 @@ MSG_IMPLEMENT_DYNAMIC(Slave, Process); int Slave::main(int argc, char** argv) { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + cout <<"[" << getName() << ":" << getHost().getName() << ": PID " << getPID() << "] " << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; - Task* receivedTask; BasicTask* basicTask; @@ -30,16 +29,20 @@ int Slave::main(int argc, char** argv) basicTask = reinterpret_cast(receivedTask); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received \"" << basicTask->getName() << "\" " << endl; + cout <<"[" << getName() << ":" << getHost().getName() << ": PID " << getPID() << "] " << "Received \"" << basicTask->getName() << "\" " << endl; - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Processing \"" << basicTask->getName() << "\" " << endl; + cout <<"[" << getName() << ":" << getHost().getName() << ": PID " << getPID() << "] " << "Processing \"" << basicTask->getName() << "\" " << endl; + basicTask->execute(); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "\"" << basicTask->getName() << "\" done " << endl; + + cout <<"[" << getName() << ":" << getHost().getName() << ": PID " << getPID() << "] " << "\"" << basicTask->getName() << "\" done " << endl; delete basicTask; } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received Finalize. I'm done. See you!" << endl; + cout <<"[" << getName() << ":" << getHost().getName() << ": PID " << getPID() << "] " << "Received Finalize. I'm done. See you!" << endl; + + delete this; return 0; } \ No newline at end of file diff --git a/examples/cxx/basic/BasicTask.hpp b/examples/cxx/basic/BasicTask.hpp index 14f8e1da8e..ca3c477026 100644 --- a/examples/cxx/basic/BasicTask.hpp +++ b/examples/cxx/basic/BasicTask.hpp @@ -17,11 +17,6 @@ public: BasicTask(const char* name, double computeDuration, double messageSize) throw (InvalidArgumentException, NullPointerException) :Task(name, computeDuration, messageSize){} - - /*virtual const BasicTask& operator = (const BasicTask& rTask) { - Task::operator=(rTask); - return *this; - }*/ }; typedef BasicTask* BasicTaskPtr; diff --git a/examples/cxx/basic/Forwarder.cxx b/examples/cxx/basic/Forwarder.cxx index 1fa5c2dc3f..d5fcdecfb7 100644 --- a/examples/cxx/basic/Forwarder.cxx +++ b/examples/cxx/basic/Forwarder.cxx @@ -65,6 +65,8 @@ int Forwarder::main(int argc, char** argv) cout <<"[" << getName() << ":" << getHost().getName() << "] " << "I'm done. See you!" << endl; delete[] slaves; + + delete this; return 0; } \ No newline at end of file diff --git a/examples/cxx/basic/Master.cxx b/examples/cxx/basic/Master.cxx index f6e06d207f..cec35f140f 100644 --- a/examples/cxx/basic/Master.cxx +++ b/examples/cxx/basic/Master.cxx @@ -4,6 +4,8 @@ #include #include +#include + #include using namespace std; @@ -82,8 +84,8 @@ int Master::main(int argc, char** argv) cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Sending \"" << todo[i]->getName() << "\" to \"" << slaves[i % slaveCount].getName() << "\"" << endl; if(!strcmp(Host::currentHost().getName(), slaves[i % slaveCount].getName())) - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hey ! It's me ! "; - + cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hey ! It's me ! "; + slaves[i % slaveCount].put(channel, todo[i]); } @@ -92,19 +94,14 @@ int Master::main(int argc, char** argv) cout <<"[" << getName() << ":" << getHost().getName() << "] " << "All tasks have been dispatched. Let's tell everybody the computation is over." << endl; for (int i = 0; i < slaveCount; i++) - { - slaves[i].put(channel, new FinalizeTask()); - } - - - for(int i = 0; i < numberOfTasks; i++) - delete todo[i]; + slaves[i].put(channel, new FinalizeTask()); delete[] todo; - delete[] slaves; cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Goodbye now!" << endl; + delete this; + return 0; } \ No newline at end of file diff --git a/examples/cxx/basic/Slave.cxx b/examples/cxx/basic/Slave.cxx index 775dd24600..10be8fca4a 100644 --- a/examples/cxx/basic/Slave.cxx +++ b/examples/cxx/basic/Slave.cxx @@ -29,9 +29,13 @@ int Slave::main(int argc, char** argv) t->execute(); cout <<"[" << getName() << ":" << getHost().getName() << "] " << "\"" << t->getName() << "\" done " << endl; + + delete t; } cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received Finalize. I'm done. See you!" << endl; + + delete this; return 0; } \ No newline at end of file diff --git a/examples/cxx/comm_time/Main.cxx b/examples/cxx/comm_time/Main.cxx index dbda264803..0b9a7f1973 100644 --- a/examples/cxx/comm_time/Main.cxx +++ b/examples/cxx/comm_time/Main.cxx @@ -8,5 +8,4 @@ main(int argc, char* argv[]) Simulation s; return s.execute(argc, argv); - } diff --git a/examples/cxx/comm_time/Master.cxx b/examples/cxx/comm_time/Master.cxx index 7ab27b6c5c..c68e8475e2 100644 --- a/examples/cxx/comm_time/Master.cxx +++ b/examples/cxx/comm_time/Master.cxx @@ -85,5 +85,8 @@ int Master::main(int argc, char** argv) cout <<"[" << getName() << ":" << getHost().getName() << "] " << "All finalize messages have been dispatched. Goodbye now!" << endl; + + delete[] slaves; + delete this; return 0; } \ No newline at end of file diff --git a/examples/cxx/comm_time/Slave.cxx b/examples/cxx/comm_time/Slave.cxx index 090fce3b9d..4a3a78bfe0 100644 --- a/examples/cxx/comm_time/Slave.cxx +++ b/examples/cxx/comm_time/Slave.cxx @@ -39,7 +39,8 @@ int Slave::main(int argc, char** argv) } cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received Finalize. I'm done. See you!" << endl; - + + delete this; return 0; } \ No newline at end of file diff --git a/examples/cxx/explicitDestination/Forwarder.cxx b/examples/cxx/explicitDestination/Forwarder.cxx index f209d1832e..6ed093ccf9 100644 --- a/examples/cxx/explicitDestination/Forwarder.cxx +++ b/examples/cxx/explicitDestination/Forwarder.cxx @@ -56,5 +56,6 @@ int Forwarder::main(int argc, char** argv) cout <<"[" << getName() << ":" << getHost().getName() << "] " << "I'm done. See you!" << endl; + delete this; return 0; } \ No newline at end of file diff --git a/examples/cxx/explicitDestination/Master.cxx b/examples/cxx/explicitDestination/Master.cxx index d3b11e8fbb..9184ee4199 100644 --- a/examples/cxx/explicitDestination/Master.cxx +++ b/examples/cxx/explicitDestination/Master.cxx @@ -89,5 +89,7 @@ int Master::main(int argc, char** argv) delete[] basicTasks; delete[] aliases; + delete this; + return 0; } \ No newline at end of file diff --git a/examples/cxx/explicitDestination/Slave.cxx b/examples/cxx/explicitDestination/Slave.cxx index fdfebb2180..6b4de500f8 100644 --- a/examples/cxx/explicitDestination/Slave.cxx +++ b/examples/cxx/explicitDestination/Slave.cxx @@ -39,6 +39,7 @@ int Slave::main(int argc, char** argv) } cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received Finalize. I'm done. See you!" << endl; - + + delete this; return 0; } \ No newline at end of file diff --git a/examples/cxx/ping_pong/Receiver.cxx b/examples/cxx/ping_pong/Receiver.cxx index 67e67a6fb3..fec2c36152 100644 --- a/examples/cxx/ping_pong/Receiver.cxx +++ b/examples/cxx/ping_pong/Receiver.cxx @@ -39,6 +39,8 @@ int Receiver::main(int argc, char** argv) cout <<"[" << getName() << ":" << getHost().getName() << "] " << " --- bw " << commSizeBw/communicationTime << " ----" << endl; cout <<"[" << getName() << ":" << getHost().getName() << "] " << "goodbye!" << endl; + + delete this; return 0; } \ No newline at end of file diff --git a/examples/cxx/ping_pong/Sender.cxx b/examples/cxx/ping_pong/Sender.cxx index 417bf73c88..d0518bab87 100644 --- a/examples/cxx/ping_pong/Sender.cxx +++ b/examples/cxx/ping_pong/Sender.cxx @@ -54,6 +54,8 @@ int Sender::main(int argc, char** argv) delete[] hostTable; + delete this; + return 0; } \ No newline at end of file diff --git a/examples/cxx/suspend/DreamMaster.cxx b/examples/cxx/suspend/DreamMaster.cxx index dd1bab9317..0bf21ec012 100644 --- a/examples/cxx/suspend/DreamMaster.cxx +++ b/examples/cxx/suspend/DreamMaster.cxx @@ -47,6 +47,8 @@ int DreamMaster::main(int argc, char** argv) cout <<"[" << getName() << ":" << getHost().getName() << "] " << "OK, goodbye now." << endl; + delete this; + return 0; } \ No newline at end of file