|
WSF
|
#include <WsfTimeDelayQueue.hpp>

Classes | |
| class | Request |
| class | RequestQueue |
| A queue of pending requests that have not been assigned to a server. More... | |
| class | FIFO_Queue |
| Adapter class for a First-In, First-Out (FIFO) queue. More... | |
| class | LIFO_Queue |
| Adapter class for a Last-In, First-Out (LIFO) queue. More... | |
| class | PriorityQueue |
| Adapter class for a priority queue. More... | |
| class | CompleteRequestEvent |
| An event scheduled to complete the request at the end of its delay time. More... | |
Public Types | |
| enum | QueuingMethod { cFIRST_IN_FIRST_OUT , cLAST_IN_FIRST_OUT , cPRIORITY , cNONE } |
| Queuing method. More... | |
Public Member Functions | |
| WsfTimeDelayQueue ()=default | |
| WsfTimeDelayQueue (const WsfTimeDelayQueue &aSrc) | |
| Copy constructor. | |
| WsfTimeDelayQueue & | operator= (const WsfTimeDelayQueue &)=delete |
| virtual | ~WsfTimeDelayQueue () |
| Destructor. | |
Internal methods. | |
The following are used for event processing. | |
| WsfPlatform * | mPlatformPtr {nullptr} |
| Pointer to the platform that owns the queue. | |
| WsfVariable< int > | mNumberOfServers {1} |
| The number of servers. | |
| std::vector< Request * > | mServers |
| QueuingMethod | mQueuingMethod {cFIRST_IN_FIRST_OUT} |
| The method of queuing requests when a server is not available. | |
| RequestQueue * | mPendingQueuePtr {nullptr} |
| Pointer to the adapter that implements the queuing methodology. | |
| unsigned int | mEventEpoch {1} |
| The current event scheduling epoch. | |
| virtual Request * | CompleteRequest (double aSimTime, Request *aRequestPtr, size_t aServerIndex) |
| unsigned int | GetEventEpoch () const |
| Return the current event scheduling epoch. | |
| WsfPlatform * | GetPlatform () const |
| Return the platform associated with the request queue. | |
| WsfSimulation * | GetSimulation () const |
| void | CleanUp () |
| Clean up all internal memory. | |
Framework Methods | |
| virtual WsfTimeDelayQueue * | Clone () const |
| Create a clone of this object. | |
| virtual bool | Initialize (double aSimTime, WsfPlatform *aPlatformPtr, WsfPlatformPart *aPlatformPartPtr, WsfScriptContext *aContextPtr) |
| virtual bool | ProcessInput (UtInput &aInput) |
| virtual void | TurnOff (double aSimTime) |
| virtual void | TurnOn (double aSimTime) |
| void | SetNumberOfServers (int aNumberOfServers) |
| virtual void | SubmitRequest (double aSimTime, Request *aRequestPtr) |
A class that implements a queue where the work performed by the servers is represented by a time delay.
The caller submits an object of derived from Request which represents the work to be performed. The request includes a specification of the amount of time needed to complete the work and the definition of a method that is called when the request has been completed. If a server is available then it will be assigned to that server, otherwise it will be put on a pending queue for the next available server.
To perform the 'work', the server will schedule an event for the completion time of the work (time work started + time needed for the request). When the event executes, it invokes Request::CompleteRequest to allow the submitter to detect that the time delay has expired and to perform any actions associated with the completion. The server is then release and will then be free to select the next highest priority pending request.
This is typically used to implement the concept of 'thinking time' or 'processing time'.
At the current time only a single first-in-first-out server is allocated.
|
default |
| WsfTimeDelayQueue::WsfTimeDelayQueue | ( | const WsfTimeDelayQueue & | aSrc | ) |
Copy constructor.
References mEventEpoch, mNumberOfServers, mPendingQueuePtr, mPlatformPtr, mQueuingMethod, mServers, and WsfTimeDelayQueue().
|
virtual |
Destructor.
References CleanUp(), and mPendingQueuePtr.
|
protected |
Clean up all internal memory.
References mPendingQueuePtr.
Referenced by TurnOff(), and ~WsfTimeDelayQueue().
|
virtual |
|
virtual |
Complete the processing of a request.
| aSimTime | The current simulation time. |
| aRequestPtr | Pointer to the request that is being completed. |
| aServerIndex | The index of the server that is completing its request. |
References WsfTimeDelayQueue::Request::CompleteRequest(), mPendingQueuePtr, and mServers.
Referenced by operator=().
|
inline |
Return the current event scheduling epoch.
References mEventEpoch.
Referenced by WsfTimeDelayQueue::CompleteRequestEvent::CompleteRequestEvent().
|
inline |
Return the platform associated with the request queue.
References mPlatformPtr.
Referenced by WsfTimeDelayQueue::CompleteRequestEvent::CompleteRequestEvent().
| WsfSimulation * WsfTimeDelayQueue::GetSimulation | ( | ) | const |
References mPlatformPtr.
Referenced by WsfTimeDelayQueue::CompleteRequestEvent::Execute(), and SubmitRequest().
|
virtual |
Initialize the object.
| aSimTime | The current simulation time. |
| aPlatformPtr | The platform that owns the request processor. |
| aPlatformPartPtr | The platform part that owns the request processor (may be zero) |
| aContextPtr | Pointer to the script context used for resolving 'reference values' (e.g.: 'number_of_servers /variable NUMBER_OF_SERVERS'). A null pointer may be provided, in which case the global script context is used. |
References cFIRST_IN_FIRST_OUT, cLAST_IN_FIRST_OUT, cNONE, cPRIORITY, mNumberOfServers, mPendingQueuePtr, mPlatformPtr, mQueuingMethod, mServers, and ok.
Referenced by operator=().
|
delete |
References Clone(), CompleteRequest(), Initialize(), ProcessInput(), SetNumberOfServers(), SubmitRequest(), TurnOff(), TurnOn(), and WsfTimeDelayQueue().
|
virtual |
References cFIRST_IN_FIRST_OUT, cLAST_IN_FIRST_OUT, cNONE, cPRIORITY, mNumberOfServers, and mQueuingMethod.
Referenced by operator=().
| void WsfTimeDelayQueue::SetNumberOfServers | ( | int | aNumberOfServers | ) |
Set the number of servers available to process requests. This is essentially the number of requests that can be processed simultaneously.
| aNumberOfServers | The number of servers. A value less than or equal to zero or >= std::numeric_limits<int>::max() will be treated as infinite. |
References mNumberOfServers, and mPlatformPtr.
Referenced by operator=().
|
virtual |
Submit a request for processing by the next available processor.
| aSimTime | The current simulation time. |
| aRequestPtr | The request to be processed. |
References WsfSimulation::AddEvent(), cNONE, GetSimulation(), mPendingQueuePtr, mQueuingMethod, mServers, and WsfTimeDelayQueue::Request::TimeRequired().
Referenced by operator=().
|
virtual |
Indicate that the request processor has been turned off.
| aSimTime | The current simulation time. |
References CleanUp(), and mEventEpoch.
Referenced by operator=().
|
virtual |
Indicate that the request processor has been turned on.
| aSimTime | The current simulation time. |
References mEventEpoch.
Referenced by operator=().
|
protected |
The current event scheduling epoch.
Referenced by GetEventEpoch(), TurnOff(), TurnOn(), and WsfTimeDelayQueue().
|
protected |
The number of servers.
Referenced by Initialize(), ProcessInput(), SetNumberOfServers(), and WsfTimeDelayQueue().
|
protected |
Pointer to the adapter that implements the queuing methodology.
Referenced by CleanUp(), CompleteRequest(), Initialize(), SubmitRequest(), WsfTimeDelayQueue(), and ~WsfTimeDelayQueue().
|
protected |
Pointer to the platform that owns the queue.
Referenced by GetPlatform(), GetSimulation(), Initialize(), SetNumberOfServers(), and WsfTimeDelayQueue().
|
protected |
The method of queuing requests when a server is not available.
Referenced by Initialize(), ProcessInput(), SubmitRequest(), and WsfTimeDelayQueue().
|
protected |
The current request being processed by each server. If an entry is zero then the server is not busy.
Referenced by CompleteRequest(), Initialize(), SubmitRequest(), and WsfTimeDelayQueue().