Virtual class representing sequential processes. More...
#include <tprocess.h>
Classes | |
class | Timeout |
timeout event More... |
Public Member Functions | |
TProcess () | |
creates a sequential process with the default stack size. | |
TProcess (unsigned long stacksize) | |
creates a sequential process with the given stack size. | |
virtual void | main ()=0 |
body of this simulated sequential process. | |
Public Member Functions inherited from ssim::Process | |
virtual void | init (void) |
action executed when the process is initialized. | |
virtual void | process_event (const Event *msg) |
action executed in response to an event signaled to this process. | |
virtual void | stop (void) |
executed when the process is explicitly stopped. |
Static Public Member Functions | |
static const Event * | wait_for_event (Time timeout=INIT_TIME) |
accepts an event over a given interval. |
Static Public Attributes | |
static unsigned long | DefaultStackSize |
default stack size for sequential processes. |
Virtual class representing sequential processes.
A simulated sequential process extends this class by implementing a main() method. The fundamental difference between the base Process and a TProcess is that a Process is implemented as a reactive object, that implements an algorithm by implementing reactions to incoming events in the form of callback functions. Conversely, a TProcess is a sequential process that implements an algorithm by simply implementing a main() function.
The tp.cc example illustrates the use of sequential processes.
ssim::TProcess::TProcess | ( | ) |
creates a sequential process with the default stack size.
|
pure virtual |
body of this simulated sequential process.
Body of this process. This process may interact with other processes by receiving and sending signals (a.k.a., events). The passage of time in this main body can be controlled through the advance_delay method.
accepts an event over a given interval.
This method suspends the execution of the current process until either an event is signaled to the current process or the given timeout expires. A (default) timeout value of INIT_TIME means an infinite timeout.
If an event is signaled before the timeout expires, this method returns that event. If the timeout expires before any event is received, this method returns a Timeout event.
This method must be called within the execution of the main() method of a TProcess. The following example illustrates a typical way to use this method:
|
static |
default stack size for sequential processes.
The initial value is 8Kb. This value can be dynamically adjusted, and will affect all newly created TProcess objects.