VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
DtCapableTaskRequester Class Reference

DtCapableTaskRequester — sends DtIfCapableTaskAndSetQuery messages to the VRF backend and applies the responses to the matching DtWebServerObject instances.

Life cycle:

  1. Construct with a reference to the shared DtWebServerObjectList.
  2. Call initialize() once the VRF API is ready to register the response callback.
  3. Call onEntityDiscovered() for each entity from DtWebServerObjectList::addedObjects().
  4. Call tick() once per VRF update tick from the VRF update thread.
  5. Call shutdown() before destroying the VRF remote controller.

Thread safety: all methods must be called exclusively from the VRF update thread, with the sole exception of queueSize() which is safe to call from any thread.

Public Member Functions

 DtCapableTaskRequester (DtWebServerObjectList &trackedObjects)
 
 DtCapableTaskRequester (const DtCapableTaskRequester &)=delete
 
DtCapableTaskRequester & operator= (const DtCapableTaskRequester &)=delete
 
void initialize (makVrf::DtVrlinkVrfRemoteController *remoteController, DtScenarioManager *scenarioManager)
 
void shutdown ()
 
void onEntityDiscovered (const DtWebServerObjectPtr &obj)
 
void tick ()
 
size_t queueSize () const
 

Private Member Functions

void processResponse (DtSimMessage *msg)
 
void sendQuery (const std::vector< DtWebServerObjectPtr > &batch)
 

Static Private Member Functions

static void onMessageReceived (DtSimMessage *msg, void *usrData)
 

Private Attributes

DtWebServerObjectList & myTrackedObjects
 
makVrf::DtVrlinkVrfRemoteController * myController = nullptr
 
DtScenarioManager * myScenarioManager = nullptr
 
std::deque< DtUUID > myRequestQueue
 
std::atomic< size_t > myQueueSize {0}
 
std::unordered_set< DtUUID > myQueuedUuids
 
std::unordered_map< DtUUID,
std::chrono::steady_clock::time_point > 
myPendingRequests
 
std::unordered_map< DtUUID, int > myDeferredObjects
 
std::unordered_map< DtUUID, int > myQueryRetryCounts
 

Static Private Attributes

static constexpr int theRetryDelayMs = 2000
 
static constexpr int theRequestsPerTick = 5
 
static constexpr int theVrfCheckMaxDeferrals = 20
 
static constexpr int theMaxQueryRetries = 5
 

Constructor & Destructor Documentation

DtCapableTaskRequester::DtCapableTaskRequester ( DtWebServerObjectList &  trackedObjects)
explicit
Parameters
trackedObjectsThe live object registry owned by DtVrfManager. Must outlive this instance.
DtCapableTaskRequester::DtCapableTaskRequester ( const DtCapableTaskRequester &  )
delete

Member Function Documentation

DtCapableTaskRequester& DtCapableTaskRequester::operator= ( const DtCapableTaskRequester &  )
delete
void DtCapableTaskRequester::initialize ( makVrf::DtVrlinkVrfRemoteController *  remoteController,
DtScenarioManager *  scenarioManager 
)

Register the VRF message-receive callback and store dependencies. Must be called after both remoteController and scenarioManager are fully initialized.

void DtCapableTaskRequester::shutdown ( )

Deregister the message callback and clear all queued state. Must be called before the remoteController is destroyed.

void DtCapableTaskRequester::onEntityDiscovered ( const DtWebServerObjectPtr &  obj)

Notify that a new simulation object has been discovered. VRF-simulated objects are enqueued immediately; others are deferred until their isVrfSimulatedObject() flag becomes true (typically within a few ticks).

void DtCapableTaskRequester::tick ( )

Process per-tick work: promote deferred objects, retry timed-out requests, and dispatch pending queries to the VRF backend. Must be called once per tick from the VRF update thread.

size_t DtCapableTaskRequester::queueSize ( ) const
inline

Returns the number of entities waiting to be dispatched in the capable-task request queue. Does not include in-flight requests awaiting a response. Safe to call from any thread.

References myQueueSize.

Referenced by DtVrfManager::capableTaskQueueSize().

static void DtCapableTaskRequester::onMessageReceived ( DtSimMessage *  msg,
void *  usrData 
)
staticprivate

VRF message callback — invoked on the VRF update thread when a DtCapableTaskAndSetResponseType message is received.

void DtCapableTaskRequester::processResponse ( DtSimMessage *  msg)
private

Unpack and apply a single DtCapableTaskAndSetResponse message.

void DtCapableTaskRequester::sendQuery ( const std::vector< DtWebServerObjectPtr > &  batch)
private

Build and send a DtIfCapableTaskAndSetQuery for the given objects.

Member Data Documentation

DtWebServerObjectList& DtCapableTaskRequester::myTrackedObjects
private
makVrf::DtVrlinkVrfRemoteController* DtCapableTaskRequester::myController = nullptr
private
DtScenarioManager* DtCapableTaskRequester::myScenarioManager = nullptr
private
constexpr int DtCapableTaskRequester::theRetryDelayMs = 2000
staticprivate

Retry delay before re-sending a query that received no response.

constexpr int DtCapableTaskRequester::theRequestsPerTick = 5
staticprivate

Maximum number of capable-task queries dispatched per tick (rate limiting).

constexpr int DtCapableTaskRequester::theVrfCheckMaxDeferrals = 20
staticprivate

Maximum per-tick deferrals before giving up on a non-VRF-simulated entity.

constexpr int DtCapableTaskRequester::theMaxQueryRetries = 5
staticprivate

Maximum times a query is retried before giving up on an unresponsive entity.

std::deque<DtUUID> DtCapableTaskRequester::myRequestQueue
private
std::atomic<size_t> DtCapableTaskRequester::myQueueSize {0}
private

Mirrors myRequestQueue.size() as an atomic for thread-safe reads via queueSize().

Referenced by queueSize().

std::unordered_set<DtUUID> DtCapableTaskRequester::myQueuedUuids
private

Tracks UUIDs currently in myRequestQueue to prevent duplicate entries.

std::unordered_map<DtUUID, std::chrono::steady_clock::time_point> DtCapableTaskRequester::myPendingRequests
private

UUID -> timestamp of last query dispatch. Entries are erased when a response arrives or when the retry delay expires and the entry is re-queued.

std::unordered_map<DtUUID, int> DtCapableTaskRequester::myDeferredObjects
private

Entities waiting for their isVrfSimulatedObject() flag to become true. Value is the number of ticks spent waiting.

std::unordered_map<DtUUID, int> DtCapableTaskRequester::myQueryRetryCounts
private

Retry count per UUID; reset when a response arrives or the entity is re-queued via onEntityDiscovered.


The documentation for this class was generated from the following file:

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)