00001
00002
00003 #include "LargeCarrot.h"
00004 #include "LargeOnion.h"
00005 #include <ipc/core.h>
00006 #include <unistd.h>
00007
00008
00009 void doStuff(const unsigned int i) {
00010 std::cout << "Starting doStuff for the " << i << "-th time ... " << std::endl;
00011 std::cout << "Making a carrot ..." << std::endl;
00012 LargeCarrot & largeCarrot = *(new LargeCarrot);
00013
00014
00015
00016
00017 std::cout << "Waiting for carrot to finish blocking ..." << std::endl;
00018 largeCarrot.run();
00019 std::cout << "Quiting as carrot finished blocking ..." << std::endl;
00020
00021 std::cout << "Calling largeCarrot._destroy() ... " << std::endl;
00022 largeCarrot._destroy();
00023
00024
00025
00026
00027 std::cout << "... finishing doStuff" << std::endl;
00028 };
00029
00030 int main(int argc, char * argv[]) {
00031 std::cout << "Before I will do much that is of use you will need to run the following two commands:\n" << std::endl;
00032 std::cout << "\tipc_server &\n\tipc_server -p SCT &\n\n";
00033 std::cout << "which will start up the necessary partitions into which the objects created in this file will be published.\n" << std::endl;
00034 std::cout << "NB. Should you want to do so, you could remotely shut down the onions and carrots with:\n\n\tipc_rm -p SCT --interface Stew/Onion --name LargeOnionName\n\tipc_rm -p SCT --interface Stew/Carrot --name LargeCarrotName\n\n" << std::flush;
00035
00036 std::cout << "Initialising IPC ..." << std::endl;
00037 IPCCore::init(argc, argv);
00038
00039 std::cout << "Making SCT partition..." << std::endl;
00040 IPCPartition partition("SCT");
00041
00042 for(unsigned int i=0; i<500; ++i) {
00043 doStuff(i);
00044 };
00045
00046 const unsigned int s=0;
00047 std::cout << "Sleeping for " << s << " seconds." << std::endl;
00048 sleep(s);
00049
00050 std::cout << "Bye" << std::endl;
00051 };