00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifdef HAVE_CONFIG_H
00018 #include "config.h"
00019 #endif
00020
00021 #ifndef AGENT_WATCHER_H
00022 #define AGENT_WATCHER_H
00023
00024 #include <zthread/Thread.h>
00025 #include <zthread/Mutex.h>
00026 #include <zthread/Semaphore.h>
00027 #include <zthread/CountingSemaphore.h>
00028 #include <zthread/Guard.h>
00029 #include <dalt_client/run_time_info.h>
00030
00031 using namespace ZThread;
00032 using namespace std;
00033
00034 namespace DALT_Client {
00035
00042 class AgentWatcher : public Thread
00043 {
00044 private:
00046 int agents;
00048 Semaphore* loop_locker;
00050 Mutex rti_mutex;
00052 Mutex agents_mutex;
00054 Mutex l_mon;
00056 bool locker_idle;
00058 CountingSemaphore* agent_sem;
00060 RunTimeInfo rti;
00062 AgentWatcher* self_reference;
00064 bool is_new_cycle;
00066 bool first_run;
00067
00068 public:
00070 AgentWatcher(AgentWatcher*& ref);
00072 ~AgentWatcher();
00074 void agentFinished();
00077 void addAgentsToWatch(int n);
00079 void newCycle();
00080
00081 unsigned long int getLastCycleTime();
00082
00083 unsigned long int getAverageCycleTime();
00085 virtual void run() throw();
00086 };
00087
00088 }
00089
00090 #endif