WSF
WsfTimeDelayQueue Class Reference

#include <WsfTimeDelayQueue.hpp>

Collaboration diagram for WsfTimeDelayQueue:

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.
WsfTimeDelayQueueoperator= (const WsfTimeDelayQueue &)=delete
virtual ~WsfTimeDelayQueue ()
 Destructor.

Internal methods.

The following are used for event processing.

WsfPlatformmPlatformPtr {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.
RequestQueuemPendingQueuePtr {nullptr}
 Pointer to the adapter that implements the queuing methodology.
unsigned int mEventEpoch {1}
 The current event scheduling epoch.
virtual RequestCompleteRequest (double aSimTime, Request *aRequestPtr, size_t aServerIndex)
unsigned int GetEventEpoch () const
 Return the current event scheduling epoch.
WsfPlatformGetPlatform () const
 Return the platform associated with the request queue.
WsfSimulationGetSimulation () const
void CleanUp ()
 Clean up all internal memory.

Framework Methods

virtual WsfTimeDelayQueueClone () 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)

Detailed Description

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.

Member Enumeration Documentation

◆ QueuingMethod

Queuing method.

Enumerator
cFIRST_IN_FIRST_OUT 

First-in, first-out queuing.

cLAST_IN_FIRST_OUT 

Last-in, first-out queuing.

cPRIORITY 

Priority queuing.

cNONE 

No queuing.

Constructor & Destructor Documentation

◆ WsfTimeDelayQueue() [1/2]

◆ WsfTimeDelayQueue() [2/2]

WsfTimeDelayQueue::WsfTimeDelayQueue ( const WsfTimeDelayQueue & aSrc)

◆ ~WsfTimeDelayQueue()

WsfTimeDelayQueue::~WsfTimeDelayQueue ( )
virtual

Destructor.

References CleanUp(), and mPendingQueuePtr.

Member Function Documentation

◆ CleanUp()

void WsfTimeDelayQueue::CleanUp ( )
protected

Clean up all internal memory.

References mPendingQueuePtr.

Referenced by TurnOff(), and ~WsfTimeDelayQueue().

◆ Clone()

WsfTimeDelayQueue * WsfTimeDelayQueue::Clone ( ) const
virtual

Create a clone of this object.

References WsfTimeDelayQueue().

Referenced by operator=().

◆ CompleteRequest()

WsfTimeDelayQueue::Request * WsfTimeDelayQueue::CompleteRequest ( double aSimTime,
Request * aRequestPtr,
size_t aServerIndex )
virtual

Complete the processing of a request.

Parameters
aSimTimeThe current simulation time.
aRequestPtrPointer to the request that is being completed.
aServerIndexThe index of the server that is completing its request.
Returns
A pointer to the request to be processed. If zero then there is no more work for the server to do. If the pointer is non-zero then the request is either the next unprocessed element from the request queue, or is the same request if the request extended its processing time.

References WsfTimeDelayQueue::Request::CompleteRequest(), mPendingQueuePtr, and mServers.

Referenced by operator=().

◆ GetEventEpoch()

unsigned int WsfTimeDelayQueue::GetEventEpoch ( ) const
inline

Return the current event scheduling epoch.

References mEventEpoch.

Referenced by WsfTimeDelayQueue::CompleteRequestEvent::CompleteRequestEvent().

◆ GetPlatform()

WsfPlatform * WsfTimeDelayQueue::GetPlatform ( ) const
inline

Return the platform associated with the request queue.

References mPlatformPtr.

Referenced by WsfTimeDelayQueue::CompleteRequestEvent::CompleteRequestEvent().

◆ GetSimulation()

WsfSimulation * WsfTimeDelayQueue::GetSimulation ( ) const

◆ Initialize()

bool WsfTimeDelayQueue::Initialize ( double aSimTime,
WsfPlatform * aPlatformPtr,
WsfPlatformPart * aPlatformPartPtr,
WsfScriptContext * aContextPtr )
virtual

Initialize the object.

Parameters
aSimTimeThe current simulation time.
aPlatformPtrThe platform that owns the request processor.
aPlatformPartPtrThe platform part that owns the request processor (may be zero)
aContextPtrPointer 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.
Returns
true if successful and false if not.

References cFIRST_IN_FIRST_OUT, cLAST_IN_FIRST_OUT, cNONE, cPRIORITY, mNumberOfServers, mPendingQueuePtr, mPlatformPtr, mQueuingMethod, mServers, and ok.

Referenced by operator=().

◆ operator=()

◆ ProcessInput()

bool WsfTimeDelayQueue::ProcessInput ( UtInput & aInput)
virtual

◆ SetNumberOfServers()

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.

Parameters
aNumberOfServersThe number of servers. A value less than or equal to zero or >= std::numeric_limits<int>::max() will be treated as infinite.
Note
This is only effective prior to Initialize being called.

References mNumberOfServers, and mPlatformPtr.

Referenced by operator=().

◆ SubmitRequest()

void WsfTimeDelayQueue::SubmitRequest ( double aSimTime,
Request * aRequestPtr )
virtual

Submit a request for processing by the next available processor.

Parameters
aSimTimeThe current simulation time.
aRequestPtrThe request to be processed.

References WsfSimulation::AddEvent(), cNONE, GetSimulation(), mPendingQueuePtr, mQueuingMethod, mServers, and WsfTimeDelayQueue::Request::TimeRequired().

Referenced by operator=().

◆ TurnOff()

void WsfTimeDelayQueue::TurnOff ( double aSimTime)
virtual

Indicate that the request processor has been turned off.

Parameters
aSimTimeThe current simulation time.

References CleanUp(), and mEventEpoch.

Referenced by operator=().

◆ TurnOn()

void WsfTimeDelayQueue::TurnOn ( double aSimTime)
virtual

Indicate that the request processor has been turned on.

Parameters
aSimTimeThe current simulation time.

References mEventEpoch.

Referenced by operator=().

Member Data Documentation

◆ mEventEpoch

unsigned int WsfTimeDelayQueue::mEventEpoch {1}
protected

The current event scheduling epoch.

Referenced by GetEventEpoch(), TurnOff(), TurnOn(), and WsfTimeDelayQueue().

◆ mNumberOfServers

WsfVariable<int> WsfTimeDelayQueue::mNumberOfServers {1}
protected

The number of servers.

Referenced by Initialize(), ProcessInput(), SetNumberOfServers(), and WsfTimeDelayQueue().

◆ mPendingQueuePtr

RequestQueue* WsfTimeDelayQueue::mPendingQueuePtr {nullptr}
protected

Pointer to the adapter that implements the queuing methodology.

Referenced by CleanUp(), CompleteRequest(), Initialize(), SubmitRequest(), WsfTimeDelayQueue(), and ~WsfTimeDelayQueue().

◆ mPlatformPtr

WsfPlatform* WsfTimeDelayQueue::mPlatformPtr {nullptr}
protected

Pointer to the platform that owns the queue.

Referenced by GetPlatform(), GetSimulation(), Initialize(), SetNumberOfServers(), and WsfTimeDelayQueue().

◆ mQueuingMethod

QueuingMethod WsfTimeDelayQueue::mQueuingMethod {cFIRST_IN_FIRST_OUT}
protected

The method of queuing requests when a server is not available.

Referenced by Initialize(), ProcessInput(), SubmitRequest(), and WsfTimeDelayQueue().

◆ mServers

std::vector<Request*> WsfTimeDelayQueue::mServers
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().


The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved