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

IDEA::TimingService Class Reference
[TimingService]

The TimingService is the 'central' place of time for all agents on one machine. Will activate/wake-up agents at certain times based upon information from these agents. The communication of this information is done via shared (between processes) memory. We have a central notion time in specific for debugging reasons so we can warp time and scale time. More...

#include <TimingService.hh>

List of all members.

Public Methods

 TimingService (int tscale=1, bool warp=false, const Time &offset=Time(0, 0), const std::string &poolName="TimingService")
 Constructor.

 ~TimingService ()
 Destructor.

SharedTimingServicegetSharedTimingService () const
 Returns SharedTimingService instance associated with the invoking timing service.

int run (bool wait=true)
 Will start the running of the invoking TimingService instance.

void spin ()
 Starts spinning the thread of the invoking timing service. The thread is responsible for listening to events like setting/canceling the timer.

void stopSpinning ()

Private Types

enum  TimerActionType {
  TIMER_ACTION_UNINITIALIZED = 0, SET_TIMER, RESET_TIMER, CANCEL_TIMER,
  TIMER_ACTION_LIMIT
}
 Differennt actions which can be requested to be executed by the thread of the invoking timing service. More...


Private Methods

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)
 Activates the timing-service thread; Hard-coded to be limited to one thread.

int svc (void)
 Top-level thread function, executes requested actions.

int createSharedTimingService ()
 Creates a SharedTimingService instance in shared-memory.

void setTimer (int agent, const Time &simulationTime)
 Sets a TimerHandler to be invoked in sec seconds and nsec nano-seconds.

void cancelTimer ()
 Cancels the last set timer-event (there is only supposed to be one event always).

bool serverInsertTimer ()
 Inserts a timer event in the queue of events.

bool serverCheckWarping ()
 Checks if warping is appropriate given the sate of the timing servic and warps if possible.

bool serverHandleWakeup ()
 Handles a wakeup.

bool serverCancelTimer ()
 Handles a cancellation of the last set timer.

bool serverSetActiveTimer (bool reset)
 Sets the invoking timing service to be woken up by the OS at the appropriate time (next event given timescale).

bool serverReactorRequest (TimerActionType action, int agent, const Time &simulationTime)
 Handles a request for an action.

void serverFailure ()
 Communicates server failure to clients.


Private Attributes

SharedTimingServicem_SharedTimingService
bool m_ServerFailed
bool m_ServerRunning
bool m_ServerThreadDone
bool m_WarpEnabled
int m_EventTimerId
int m_TimeScale
Time m_EarliestWakeUpTime
Time m_Offset
Time m_TimerDataNextEvent
TimingServiceStopper m_Stopper


Detailed Description

The TimingService is the 'central' place of time for all agents on one machine. Will activate/wake-up agents at certain times based upon information from these agents. The communication of this information is done via shared (between processes) memory. We have a central notion time in specific for debugging reasons so we can warp time and scale time.

Class TimingService


Member Enumeration Documentation

enum IDEA::TimingService::TimerActionType [private]
 

Differennt actions which can be requested to be executed by the thread of the invoking timing service.

Enumeration values:
TIMER_ACTION_UNINITIALIZED 
SET_TIMER 
RESET_TIMER 
CANCEL_TIMER 
TIMER_ACTION_LIMIT 


Constructor & Destructor Documentation

IDEA::TimingService::TimingService int    tscale = 1,
bool    warp = false,
const Time   offset = Time(0, 0),
const std::string &    poolName = "TimingService"
 

Constructor.

IDEA::TimingService::~TimingService  
 

Destructor.


Member Function Documentation

int IDEA::TimingService::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
[private]
 

Activates the timing-service thread; Hard-coded to be limited to one thread.

void IDEA::TimingService::cancelTimer   [private]
 

Cancels the last set timer-event (there is only supposed to be one event always).

these things are ref-counted! that is garbage collected

int IDEA::TimingService::createSharedTimingService   [private]
 

Creates a SharedTimingService instance in shared-memory.

Uses the allocator created by TimingService::createSharedMemoryAllocator and will use binding name SharedTimingService::getSharedMemoryBindName as key to map the shared memory block.

SharedTimingService * IDEA::TimingService::getSharedTimingService  
 

Returns SharedTimingService instance associated with the invoking timing service.

int IDEA::TimingService::run bool    wait = true
 

Will start the running of the invoking TimingService instance.

Will activate the thread of the invoking TimingService. The thread tries to acquire a semaphore of the shared-timing-service and once it has acquired the semaphore it will process the server-action of the SharedTimingService instance associated with the invoking instance (SharedTimingService::getServerAction). The following action-types exist:

  • STS_WAKEUP_DELETE, will iterate over all the stored TimerMapEntry instances in the global timeEventMap for which its time is equal to the time of the server-action of the SharedTimingService and release process-semaphore for the agent that is associated with these TimerMapEntry and then removes the TimerMapEntry. The releasing of the process-semaphore should trigger the continuation of the thread of the IdeaTimingService which in itself will invoke the pure virtual method handleWakeupCall of the same IdeaTimingService (all this is implemented in TimingService::serverHandleWakeup). Will also set the next time the semaphore of the invoking timing-service need to be released (by TimerHandler via the ACE_Reactor)
  • STS_CANCEL_DELETE,will iterate over all the stored TimerMapEntry instances in the global timeEventMap for which its time is equal to the time of the server-action of the SharedTimingService and delete these events. Will also set the next time the semaphore of the invoking timing-service need to be released (by TimerHandler via the ACE_Reactor)
  • STS_INSERT, will store a TimerMapEntry in the global timeEventMap using the server-action data in the shared-timing-service. Does also the re-setting of the wake-up time if needed.
  • STS_CHECK_WARPING, checks if we can warp and does so if possible.
The semaphore of the shared-timing-service is released by TimerHandler instances set by several methods that are being invoked via IdeaTimingService (which is at the Agent level).

bool IDEA::TimingService::serverCancelTimer   [private]
 

Handles a cancellation of the last set timer.

bool IDEA::TimingService::serverCheckWarping   [private]
 

Checks if warping is appropriate given the sate of the timing servic and warps if possible.

void IDEA::TimingService::serverFailure   [private]
 

Communicates server failure to clients.

bool IDEA::TimingService::serverHandleWakeup   [private]
 

Handles a wakeup.

bool IDEA::TimingService::serverInsertTimer   [private]
 

Inserts a timer event in the queue of events.

bool IDEA::TimingService::serverReactorRequest TimerActionType    action,
int    agent,
const Time   simulationTime
[private]
 

Handles a request for an action.

bool IDEA::TimingService::serverSetActiveTimer bool    reset [private]
 

Sets the invoking timing service to be woken up by the OS at the appropriate time (next event given timescale).

void IDEA::TimingService::setTimer int    agent,
const Time   simulationTime
[private]
 

Sets a TimerHandler to be invoked in sec seconds and nsec nano-seconds.

void IDEA::TimingService::spin  
 

Starts spinning the thread of the invoking timing service. The thread is responsible for listening to events like setting/canceling the timer.

void IDEA::TimingService::stopSpinning  
 

int IDEA::TimingService::svc void    [private]
 

Top-level thread function, executes requested actions.


Member Data Documentation

Time IDEA::TimingService::m_EarliestWakeUpTime [private]
 

int IDEA::TimingService::m_EventTimerId [private]
 

Time IDEA::TimingService::m_Offset [private]
 

bool IDEA::TimingService::m_ServerFailed [private]
 

bool IDEA::TimingService::m_ServerRunning [private]
 

bool IDEA::TimingService::m_ServerThreadDone [private]
 

SharedTimingService* IDEA::TimingService::m_SharedTimingService [private]
 

TimingServiceStopper IDEA::TimingService::m_Stopper [private]
 

Time IDEA::TimingService::m_TimerDataNextEvent [private]
 

int IDEA::TimingService::m_TimeScale [private]
 

bool IDEA::TimingService::m_WarpEnabled [private]
 


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