00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __loaded__ao_pool_cpp__
00021 #define __loaded__ao_pool_cpp__
00022 using namespace std;
00023 #line 1 "ao-pool.c++"
00024 #include <cstdio>
00025 #include <iostream>
00026 #include "ao-pool.h"
00027 #include "ao-tracker.h"
00028 #include "ao-scheduler.h"
00029
00044 class StdDawnTilDusk: public DawnTilDusk
00045 {
00046 SpawnWhenActivated scheduler;
00047 AoTracker *tracker;
00048 volatile bool running;
00049 public:
00050 StdDawnTilDusk(): scheduler()
00051 {
00052
00053 tracker=NULL;
00054 aoPool=this;
00055 tracker=new AoTracker();
00056 running=true;
00057 }
00058 ~StdDawnTilDusk()
00059 {
00060 assert(!running);
00061 delete tracker;
00062 }
00067 virtual Scheduler * sunrise(string who)
00068 {
00069 if (tracker) tracker->sunrise(who);
00070 return &scheduler;
00071 };
00076 virtual void sunset(string who)
00077 {
00078 assert(tracker);
00079 if (who=="AoTracker") running=false;
00080 else tracker->sunset(who);
00081 };
00082 virtual void wait_for_finish()
00083 {
00084 while(running)
00085 {
00086 sleep(1);
00087 if (running)
00088 {
00089 cout<<"Waiting for objects to finish\n";
00090 print_active_object_list();
00091 cout.flush();
00092 }
00093 }
00094 };
00098 virtual void print_active_object_list()
00099 {
00100 assert(tracker);
00101 tracker->print();
00102 }
00103 };
00104
00105 DawnTilDusk * aoPool = new StdDawnTilDusk();
00106 #endif // __loaded__ao_pool_cpp__