LPeriodical is an abstract PowerPlant base class that is multiply inherited by other framework objects. It is used for giving objects the ability to do work at periodic intervals. In PowerPlant, an object that receives processor time on a periodic basis is said to be a Periodical.
Since LPeriodical is an abstract base class, you can't instantiate an LPeriodical object. Instead, you inherit from LPeriodical in your object's class definition, and define any overrides of the base class methods needed by your object.
This class maintains two static queues, an Idler queue and a Repeater queue. It is up to the caller to determine the meaning of each queue and when to devote time to the Periodicals in them. The PowerPlant LApplication class devotes time to Idlers at Null Event time, and devotes time to Repeaters after every event.
Methods :
The methods in this class are:
Data Members:
The data members in this class are:
Operation:
Many different objects in your program may require processor time on a periodic basis. For example, changing the text edit insertion caret in LEditField requires that some periodic operations are performed. Another example is LGrowZone(), which requires periodic polling of memory conditions in order to be effective at handling low-memory situations.
There are two different kinds of periodical objects that you create:
An Idler object is an object that gets processing time when the application gets a null event. In other words, when the application thread has nothing else to do, it will process the Idler queue.
A Repeater object is an object that gets processing time after every event.
Source files:
See also:
Purpose:
The constructor for LPeriodical doesn't do anything.
Access:
Prototype:
LPeriodical();Parameters:
Return:
Purpose:
The destructor for LPeriodical stops the Idler and Repeater queue processing.
Access:
Prototype:
virtual ~LPeriodical();Parameters:
Return:
DeleteIdlerAndRepeaterQueues()
Purpose:
This method deletes the internal queues used to store pointers to Idler and Repeater objects. This method does not delete the Idler and Repeater objects themselves.
You don't need to call this when quitting an application, since
the queues will disappear when the System deallocates the application
heap. However, you may want to call this if you like deleting
every object that is created via the new operator.
Access:
Prototype:
static void DeleteIdlerAndRepeaterQueues();Parameters:
Return:
Remarks:
Normally, you will only use this routine to clean up memory when terminating a code resource or fragment. You do not normally need to call this method in from application code.
Purpose:
This method calls SpendTime() for each Periodical object in the Idler queue. This gives each object some procesing time.
Access:
Prototype:
static void DevoteTimeToIdlers(Parameters:
const EventRecord &inMacEvent);
This method has the following parameter:
| const EventRecord& |
inMacEvent | A struct containing the parameters from the last event that occurred. |
Return:
Purpose:
This method calls SpendTime() for each Periodical object in the Repeater queue. This gives each object some procesing time.
Access:
Prototype:
static void DevoteTimeToRepeaters(Parameters:
const EventRecord &inMacEvent);
This method has the following parameter:
| const EventRecord& |
inMacEvent | A struct containing the parameters from the last event that occurred. |
Return:
Purpose:
This method is a pure virtual method. You must override it in your concrete classes. You provide code that implements the operations that are required for your object to perform when it is given processing time.
Access:
Prototype:
virtual void SpendTime(Parameters:
const EventRecord &inMacEvent) = 0;
This method has the following parameter:
| const EventRecord& |
inMacEvent | A struct containing the parameters from the last event that occurred. |
Return:
Purpose:
This method creates an Idler queue if one doesn't already exist. Then, it adds this Periodical object to the end of the queue if it isn't already in there.
Access:
Prototype:
virtual void StartIdling();Parameters:
Return:
Purpose:
This method creates a Repeater queue if one doesn't already exist. Then, it adds this Periodical object to the end of the queue if it isn't already in there.
Access:
Prototype:
virtual void StartRepeating();Parameters:
Return:
Purpose:
Remove this Periodical object from the Idler queue.
Access:
Prototype:
virtual void StopIdling();Parameters:
Return:
Purpose:
Remove this Periodical object from the Repeater queue.
Access:
Prototype:
virtual void StopRepeating();Parameters:
Return:
Purpose:
This data member is a pointer to a TArray of pointers to LPeriodical objects. In short, this data member is a pointer to a list of objects in the Idler queue.
Access:
Prototype:
static TArray<LPeriodical*> *sIdlerQ;Remarks :
In general, you will want to use the methods in the LPeriodical class to manipulate the sIdlerQ list, rather than accessing it directly.
Purpose:
This data member is a pointer to a TArray of pointers to LPeriodical objects. In short, this data member is a pointer to a list of objects in the Repeater queue.
Access:
Prototype:
static TArray<LPeriodical*> *sRepeaterQ;Remarks:
In general, you will want to use the methods in the LPeriodical class to manipulate the sRepeaterQ list, rather than accessing it directly.