Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

/home/pauldt/projects/IDEA/IDEA-ALL/IDEA-DEV/Modules/SharedTimingService/Includes/SharedTimingServiceImpl.hh

Go to the documentation of this file.
00001 // -*- Mode: c++ -*-
00002 //     File: $Source: /home/cvs/ISG-Repository/IDEA-DEV/Modules/SharedTimingService/Includes/SharedTimingServiceImpl.hh,v $
00003 //      Tag: $Name: DR_01_11_06 $
00004 //      CVS: $Id: SharedTimingServiceImpl.hh,v 1.9 2005/12/30 22:46:05 rijsman Exp $
00005 //     Info: $CVSROOT/IDEA-DEV/COPYRIGHT
00006 
00007 #ifndef IDEA_AGENT_TIMING_SERVICE_IMPL_H
00008 #define IDEA_AGENT_TIMING_SERVICE_IMPL_H
00009 
00010 #include <map>
00011 
00012 #include "AgentTimingServiceImpl.hh"
00013 #include "SharedTimingService.hh"
00014 
00015 namespace IDEA
00016 {
00022   struct CompareFunc
00023   {
00024     bool operator()( const Time& lhs, const Time& rhs ) const
00025     {
00026       return lhs < rhs;
00027     }
00028   };
00029 
00036   class SharedTimingServiceImpl:
00037     public AgentTimingServiceImpl,
00038     public ACE_Task_Base
00039   {
00040   public:
00049     SharedTimingServiceImpl( const std::string& name, const std::string& poolName );
00053     ~SharedTimingServiceImpl();
00057     RecursiveThreadMutex& getMutex();
00061     bool getNextScheduledTime( Time& time );
00066     void setCancellableEventTimer(const Time& time);
00070     void cancelEventTimer();
00074     void setRebootTimer(const Time& time);
00078     void cancelRebootTimer();
00082     void setNonCancellableEventTimer(const Time& time);
00086     void cancelAllTimers(); // for graceful shutdown
00091     bool isInitialized() const; 
00095     Time getCurrentTime();
00100     Time getElapsedTime();
00104     Time getTimeOfDay();
00109     void setAgentNotActive(); 
00114     void setAgentActive();
00118    void incrementTransitMessages(int numOfMsgs=1);
00122     void decrementTransitMessages(int numOfMsgs=1);
00126     void cancelTimer( const Time& time );
00132     void incrementNonWarpableCommands();
00138     void decrementNonWarpableCommands();
00142     int activate(long flags=THR_NEW_LWP|THR_JOINABLE|THR_INHERIT_SCHED, int n_threads=1, int force_active=0, long priority=ACE_DEFAULT_THREAD_PRIORITY, int grp_id=-1, ACE_Task_Base *task=0, ACE_hthread_t thread_handles[]=0, void *stack[]=0, size_t stack_size[]=0, ACE_thread_t thread_ids[]=0); 
00143   protected:
00144      enum TimerType
00145        {
00146          TYPE_OF_TIMER_UNINITIALIZED=0,
00147          CANCELLABLE_EVENT_TIMER,
00148          NON_CANCELLABLE_EVENT_TIMER,
00149          NON_CANCELLABLE_AND_CANCELLABLE_EVENT_TIMERS,
00150          REBOOT_TIMER,
00151          CANCELLABLE_EVENT_AND_REBOOT_TIMERS,
00152          NON_CANCELLABLE_EVENT_AND_REBOOT_TIMERS,
00153          NON_CANCELLABLE_AND_CANCELLABLE_EVENT_AND_REBOOT_TIMERS,
00154          TYPE_OF_TIMER_LIMIT
00155        };
00156 
00157     typedef std::map< Time, TimerType, CompareFunc > AgentTimerMap;
00158 
00159     typedef AgentTimerMap::iterator AgentTimerMapIter;
00160 
00161     AgentTimerMap m_AgentTimerMap;
00162   private:
00168     bool getNextEvent( Time& time, int& type );
00172     void setTimer( const Time& time );
00176     void insertTimerInMap(const Time& time, TimerType timerType);
00180     void deleteTimerInMap(Time time, TimerType timerType);
00184     int svc();
00185   
00186     Time m_EventTime;  // state variable used for lookup (during cancellation)
00187 
00188     bool m_EventTimeScheduled;  // set to true if an eventTime appears in the map
00189     Time m_RebootTime; // state variable used for lookup (during cancellation)
00190 
00191     RecursiveThreadMutex m_Mutex;
00192 
00193     int m_NonWarpableCommands;
00194 
00195     int m_AgentIdFromTimingService;
00199     SharedTimingService* m_SharedTimingService; 
00200 
00201     bool m_CallBackThreadDone;
00202 
00203     ProcessSemaphore m_SemaphoreForCallback;
00204 
00205     bool m_Initialized;
00206   
00207   };
00208 
00209 }
00210 
00211 #endif 
00212 

Contact information
© IDEA
Generated on Fri Feb 3 17:09:42 2006 for IDEA.