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

IDEA::SharedTimingServiceImpl Class Reference

The SharedTimingServiceImpl is the implementation part of the AgentTimingService (bridge-pattern aka pimpl). This implementation implements the AgentTimingService using shared-memory (SharedTimingService). More...

#include <SharedTimingServiceImpl.hh>

Inheritance diagram for IDEA::SharedTimingServiceImpl:

IDEA::AgentTimingServiceImpl List of all members.

Public Methods

 SharedTimingServiceImpl (const std::string &name, const std::string &poolName)
 Constructor.

 ~SharedTimingServiceImpl ()
 Destructor.

RecursiveThreadMutexgetMutex ()
bool getNextScheduledTime (Time &time)
void setCancellableEventTimer (const Time &time)
 Will set a cancel-able-event timer. A cancel-able-event is an event that can be cancelled by invoking cancelEventTimer and cancelAllTimers.

void cancelEventTimer ()
void setRebootTimer (const Time &time)
void cancelRebootTimer ()
void setNonCancellableEventTimer (const Time &time)
void cancelAllTimers ()
bool isInitialized () const
 Returns whether the initiliazation process done at construction time was successful.

Time getCurrentTime ()
 Get the current (simulated) time.

Time getElapsedTime ()
 Get the elapsed system time from the time the time server was started. i.e., it is the wall clock time since the time server was started.

Time getTimeOfDay ()
 Returns the time of day as an offset of a pivot-date (typically january 1, 1970 depending on OS).

void setAgentNotActive ()
 An agent will call this function if there are no tokens using CPU and hence a candidate for warping.

void setAgentActive ()
 The active function will be called if there is atleast one token using CPU.

void incrementTransitMessages (int numOfMsgs=1)
 The sender will tell the TimingService how many messages it has sent.

void decrementTransitMessages (int numOfMsgs=1)
 The receiver will tell the TimingService how many messages it has received.

void cancelTimer (const Time &time)
 Canceling timer at time.

void incrementNonWarpableCommands ()
 Increases the number of non-warpable commands by one.

void decrementNonWarpableCommands ()
 Decrements the number of non-warpable commands by one.

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)
TimeEventHandlersetTimeEventHandler (TimeEventHandler *handler, bool deleteInstance)
const TimeEventHandlergetTimeEventHandler () const
void stop ()
 Stops the invoking AgentTimingServiceImpl.


Protected Types

typedef std::map< Time, TimerType,
CompareFunc
AgentTimerMap
typedef AgentTimerMap::iterator AgentTimerMapIter
enum  TimerType {
  TYPE_OF_TIMER_UNINITIALIZED = 0, CANCELLABLE_EVENT_TIMER, NON_CANCELLABLE_EVENT_TIMER, NON_CANCELLABLE_AND_CANCELLABLE_EVENT_TIMERS,
  REBOOT_TIMER, CANCELLABLE_EVENT_AND_REBOOT_TIMERS, NON_CANCELLABLE_EVENT_AND_REBOOT_TIMERS, NON_CANCELLABLE_AND_CANCELLABLE_EVENT_AND_REBOOT_TIMERS,
  TYPE_OF_TIMER_LIMIT
}

Protected Attributes

AgentTimerMap m_AgentTimerMap
TimeEventHandlerm_TimeEventHandler

Private Methods

bool getNextEvent (Time &time, int &type)
 Sets time and type to the the next events time and type if there is a next event and returns true. If there is no next event than it will return false. Will pop the event from the container of next events.

void setTimer (const Time &time)
 Setting timers.

void insertTimerInMap (const Time &time, TimerType timerType)
void deleteTimerInMap (Time time, TimerType timerType)
int svc ()

Private Attributes

Time m_EventTime
bool m_EventTimeScheduled
Time m_RebootTime
RecursiveThreadMutex m_Mutex
int m_NonWarpableCommands
int m_AgentIdFromTimingService
SharedTimingServicem_SharedTimingService
bool m_CallBackThreadDone
ProcessSemaphore m_SemaphoreForCallback
bool m_Initialized

Detailed Description

The SharedTimingServiceImpl is the implementation part of the AgentTimingService (bridge-pattern aka pimpl). This implementation implements the AgentTimingService using shared-memory (SharedTimingService).

class SharedTimingServiceImpl


Member Typedef Documentation

typedef std::map< Time, TimerType, CompareFunc > IDEA::SharedTimingServiceImpl::AgentTimerMap [protected]
 

typedef AgentTimerMap::iterator IDEA::SharedTimingServiceImpl::AgentTimerMapIter [protected]
 


Member Enumeration Documentation

enum IDEA::SharedTimingServiceImpl::TimerType [protected]
 

Enumeration values:
TYPE_OF_TIMER_UNINITIALIZED 
CANCELLABLE_EVENT_TIMER 
NON_CANCELLABLE_EVENT_TIMER 
NON_CANCELLABLE_AND_CANCELLABLE_EVENT_TIMERS 
REBOOT_TIMER 
CANCELLABLE_EVENT_AND_REBOOT_TIMERS 
NON_CANCELLABLE_EVENT_AND_REBOOT_TIMERS 
NON_CANCELLABLE_AND_CANCELLABLE_EVENT_AND_REBOOT_TIMERS 
TYPE_OF_TIMER_LIMIT 


Constructor & Destructor Documentation

IDEA::SharedTimingServiceImpl::SharedTimingServiceImpl const std::string &    name,
const std::string &    poolName
 

Constructor.

Constructs an instance with name name and uses poolName as key to look for shared-memory. Also constructs an AgentTimingServiveHandler which doesn't do anything. Use setSharedTimingServiceImplHandler to replace it with one you want to use.

IDEA::SharedTimingServiceImpl::~SharedTimingServiceImpl  
 

Destructor.


Member Function Documentation

int IDEA::SharedTimingServiceImpl::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
 

void IDEA::SharedTimingServiceImpl::cancelAllTimers   [virtual]
 

Implements IDEA::AgentTimingServiceImpl.

void IDEA::SharedTimingServiceImpl::cancelEventTimer   [virtual]
 

Implements IDEA::AgentTimingServiceImpl.

void IDEA::SharedTimingServiceImpl::cancelRebootTimer   [virtual]
 

Implements IDEA::AgentTimingServiceImpl.

void IDEA::SharedTimingServiceImpl::cancelTimer const Time   time [virtual]
 

Canceling timer at time.

Implements IDEA::AgentTimingServiceImpl.

void IDEA::SharedTimingServiceImpl::decrementNonWarpableCommands   [virtual]
 

Decrements the number of non-warpable commands by one.

In case the counter reaches zero we tell the invoking timingService it is no longer active.

Implements IDEA::AgentTimingServiceImpl.

void IDEA::SharedTimingServiceImpl::decrementTransitMessages int    numOfMsgs = 1 [virtual]
 

The receiver will tell the TimingService how many messages it has received.

Implements IDEA::AgentTimingServiceImpl.

void IDEA::SharedTimingServiceImpl::deleteTimerInMap Time    time,
TimerType    timerType
[private]
 

Time IDEA::SharedTimingServiceImpl::getCurrentTime   [virtual]
 

Get the current (simulated) time.

Implements IDEA::AgentTimingServiceImpl.

Time IDEA::SharedTimingServiceImpl::getElapsedTime   [virtual]
 

Get the elapsed system time from the time the time server was started. i.e., it is the wall clock time since the time server was started.

Implements IDEA::AgentTimingServiceImpl.

RecursiveThreadMutex & IDEA::SharedTimingServiceImpl::getMutex   [virtual]
 

Implements IDEA::AgentTimingServiceImpl.

bool IDEA::SharedTimingServiceImpl::getNextEvent Time   time,
int &    type
[private]
 

Sets time and type to the the next events time and type if there is a next event and returns true. If there is no next event than it will return false. Will pop the event from the container of next events.

bool IDEA::SharedTimingServiceImpl::getNextScheduledTime Time   time [virtual]
 

Implements IDEA::AgentTimingServiceImpl.

const TimeEventHandler * IDEA::AgentTimingServiceImpl::getTimeEventHandler   [inherited]
 

Time IDEA::SharedTimingServiceImpl::getTimeOfDay   [virtual]
 

Returns the time of day as an offset of a pivot-date (typically january 1, 1970 depending on OS).

Implements IDEA::AgentTimingServiceImpl.

void IDEA::SharedTimingServiceImpl::incrementNonWarpableCommands   [virtual]
 

Increases the number of non-warpable commands by one.

If we increment the value to one we notify the invoking timing-service that its active.

Implements IDEA::AgentTimingServiceImpl.

void IDEA::SharedTimingServiceImpl::incrementTransitMessages int    numOfMsgs = 1 [virtual]
 

The sender will tell the TimingService how many messages it has sent.

Implements IDEA::AgentTimingServiceImpl.

void IDEA::SharedTimingServiceImpl::insertTimerInMap const Time   time,
TimerType    timerType
[private]
 

bool IDEA::SharedTimingServiceImpl::isInitialized   [virtual]
 

Returns whether the initiliazation process done at construction time was successful.

Implements IDEA::AgentTimingServiceImpl.

void IDEA::SharedTimingServiceImpl::setAgentActive  
 

The active function will be called if there is atleast one token using CPU.

void IDEA::SharedTimingServiceImpl::setAgentNotActive  
 

An agent will call this function if there are no tokens using CPU and hence a candidate for warping.

void IDEA::SharedTimingServiceImpl::setCancellableEventTimer const Time   time [virtual]
 

Will set a cancel-able-event timer. A cancel-able-event is an event that can be cancelled by invoking cancelEventTimer and cancelAllTimers.

Implements IDEA::AgentTimingServiceImpl.

void IDEA::SharedTimingServiceImpl::setNonCancellableEventTimer const Time   time [virtual]
 

Implements IDEA::AgentTimingServiceImpl.

void IDEA::SharedTimingServiceImpl::setRebootTimer const Time   time [virtual]
 

Implements IDEA::AgentTimingServiceImpl.

TimeEventHandler * IDEA::AgentTimingServiceImpl::setTimeEventHandler TimeEventHandler   handler,
bool    deleteInstance
[inherited]
 

void IDEA::SharedTimingServiceImpl::setTimer const Time   time [private]
 

Setting timers.

void IDEA::AgentTimingServiceImpl::stop   [inherited]
 

Stops the invoking AgentTimingServiceImpl.

int IDEA::SharedTimingServiceImpl::svc   [private]
 


Member Data Documentation

int IDEA::SharedTimingServiceImpl::m_AgentIdFromTimingService [private]
 

AgentTimerMap IDEA::SharedTimingServiceImpl::m_AgentTimerMap [protected]
 

bool IDEA::SharedTimingServiceImpl::m_CallBackThreadDone [private]
 

Time IDEA::SharedTimingServiceImpl::m_EventTime [private]
 

bool IDEA::SharedTimingServiceImpl::m_EventTimeScheduled [private]
 

bool IDEA::SharedTimingServiceImpl::m_Initialized [private]
 

RecursiveThreadMutex IDEA::SharedTimingServiceImpl::m_Mutex [private]
 

int IDEA::SharedTimingServiceImpl::m_NonWarpableCommands [private]
 

Time IDEA::SharedTimingServiceImpl::m_RebootTime [private]
 

ProcessSemaphore IDEA::SharedTimingServiceImpl::m_SemaphoreForCallback [private]
 

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

A placeholder for the timing service structure in shared memory

TimeEventHandler* IDEA::AgentTimingServiceImpl::m_TimeEventHandler [protected, inherited]
 


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