#include <simulator/posix/posix_simulator.h>
Inheritance diagram for POSIX_Simulator:
Public Member Functions | |
virtual void | start (bool threaded=true) |
Start processing events at a rate determined by the time factor. | |
virtual double | getSystemTime () |
Override this method to return the current system time, expressed in system time units (usually seconds). | |
Protected Member Functions | |
virtual void | eventMutexLock () |
Override this method to lock the mutex that will be used for event related functions. | |
virtual void | eventMutexUnlock () |
Override this method to unlock the mutex that will be used for event related functions No locking by default, see CPP. | |
virtual bool | stepControlMutexTryLock () |
Override this method to try locking a mutex that will be used for controlling the simulation. | |
virtual void | stepControlMutexLock () |
Override this method to locking the mutex that will be used for controlling the simulation. | |
virtual void | stepControlMutexUnlock () |
Override this method to unlock the mutex that will be used for controlling the simulation. | |
virtual void | waitSemaphorePost () |
Override this method to increment a semaphore that will be used for waiting for a new event in the event loop. | |
virtual void | waitSemaphoreFlush () |
Override this method to flush a semaphore that will be used for waiting for a new event in the event loop. | |
virtual void | waitSemaphoreWait () |
Override this method to implement the "standard wait till semaphore count >0" call on a semaphore that will be used for waiting for a new event in the event loop. | |
virtual void | startWaitTimer (double delay) |
Override this method to start some kind of timer, that will call the timer callback provided after the given delay. | |
virtual void | cancelWaitTimer () |
Override this method to immediately stop the timer started by the startWaitTimer method. | |
Protected Attributes | |
pthread_mutex_t | event_mutex |
pthread_mutex_t | control_mutex |
sem_t | wait_semaphore |
pthread_mutex_t | timer_mutex |
pthread_cond_t | timer_condition |
pthread_mutex_t | waitSemaphoreMutex |
pthread_cond_t | waitSemaphoreCondition |
int | waitSemaphoreCounter |
double | waitDelay |
Friends | |
void * | timer_routine (void *arg) |
void * | run_routine (void *arg) |
|
Override this method to immediately stop the timer started by the startWaitTimer method. If you system does not provide such an operation, a clean implementation may be waiting for either a timout or a condition in a separate thread, and this cancel function triggers the condition. Then, by testing which of the timer or condition stopped the waiting, you can either call the timer callback or return immediately.
Reimplemented from Simulator. |
|
Override this method to lock the mutex that will be used for event related functions. The function should block as expected until the mutex is available No locking by default, see CPP. Reimplemented from Simulator. |
|
Override this method to return the current system time, expressed in system time units (usually seconds).
Reimplemented from Simulator. |
|
Start processing events at a rate determined by the time factor. This function returns immediately by default, and process the events in another thread. You may change this by setting the argument to false Of course, there is a limit at how fast you can process events, that is how small you can set the time factor for a fixed amount of events, depending on your system performances. Below this value, you'll probably see a large drift between simulated time and system time. In this case, you can gain an extra bit of performance by setting the factor to 0, which means "process the events as fast as possible".
Reimplemented from Simulator. |
|
Override this method to start some kind of timer, that will call the timer callback provided after the given delay. The delay is expressed in system time units, so implementations don't need to use the time factor. If your system does not provide timers, an implementation may be to wait in another thread for either some amount of time or some unblocking condition :
Reimplemented from Simulator. |
|
Override this method to locking the mutex that will be used for controlling the simulation. Only one thread can call step, or the event loop at the same time. The function should block as expected until the mutex is available No locking by default, see CPP. Reimplemented from Simulator. |
|
Override this method to try locking a mutex that will be used for controlling the simulation. Only one thread can call step, or the event loop at the same time. The function should return true on success, or return immediately false otherwise No locking by default, see CPP. Reimplemented from Simulator. |
|
Override this method to flush a semaphore that will be used for waiting for a new event in the event loop. By flushing, we mean that the semaphore count should be zero after this call. This call is done in a protected section such that no post will be done to the semaphore while calling this function. If your system doesn't propose better, you might thus try creating a new semaphore with 0 count. Reimplemented from Simulator. |