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/TimingService/Includes/TimingService.hh

Go to the documentation of this file.
00001 // -*- Mode: c++ -*-
00002 //   File: $CVSROOT/IdeaCore/TimingService/TimingService.hh
00003 //   Info: $CVSROOT/IdeaCore/Copyright.txt
00004 //   CVS: $Id: TimingService.hh,v 1.3 2005/07/11 18:17:05 rijsman Exp $
00005 //  Purpose: 
00006 
00007 #ifndef TIMING_SERVICE_H
00008 #define TIMING_SERVICE_H
00009 
00010 #include "TimeBasics.hh"
00011 
00012 #include "TimingServiceStopper.hh"
00013 
00014 #include <ace/Task.h>
00015 #include <map>
00016 
00017 namespace IDEA
00018 {
00026   struct EarliestTimeFirst
00027   {
00028     bool operator()(const Time& lhs, const Time& rhs) const
00029     {
00030       return lhs < rhs;
00031     }
00032   };
00033 
00037   typedef std::multimap< Time, int, EarliestTimeFirst> Time2IntMap;
00038 
00039   class SharedTimingService;
00040 
00052   class TimingService:
00053     public ACE_Task_Base
00054   {
00055   public:
00059     TimingService( int tscale = 1, 
00060                    bool warp = false, 
00061                    const Time& offset = Time(0,0), 
00062                    const std::string& poolName = "TimingService" );
00066     ~TimingService();
00070     SharedTimingService* getSharedTimingService() const;
00098     int run( bool wait = true );
00103     void spin();
00107     void stopSpinning();
00108   private:
00113     enum TimerActionType 
00114       {
00115         TIMER_ACTION_UNINITIALIZED=0,
00116         SET_TIMER,
00117         RESET_TIMER,
00118         CANCEL_TIMER,
00119         TIMER_ACTION_LIMIT
00120       };
00124     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); 
00128     int svc(void);
00135     int createSharedTimingService();
00139     void setTimer( int agent, const Time& simulationTime );
00143     void cancelTimer();
00147     bool serverInsertTimer(); 
00152     bool serverCheckWarping();
00156     bool serverHandleWakeup();
00160     bool serverCancelTimer();
00165     bool serverSetActiveTimer(bool reset);
00169     bool serverReactorRequest( TimerActionType action, int agent, const Time& simulationTime );
00173     void serverFailure();
00174 
00175     SharedTimingService* m_SharedTimingService;
00176 
00177     bool m_ServerFailed;       
00178     bool m_ServerRunning;      
00179     bool m_ServerThreadDone;   
00180     bool m_WarpEnabled;
00181 
00182     int m_EventTimerId;
00183     int m_TimeScale;
00184 
00185     Time m_EarliestWakeUpTime; 
00186     Time m_Offset;
00187     Time m_TimerDataNextEvent;
00188 
00189     TimingServiceStopper m_Stopper;
00190   };
00191 
00192 }
00193 
00194 #endif // TIMING_SERVICE_H

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