DtCapableTaskRequester — sends DtIfCapableTaskAndSetQuery messages to the VRF backend and applies the responses to the matching DtWebServerObject instances.
Life cycle:
- Construct with a reference to the shared DtWebServerObjectList.
- Call initialize() once the VRF API is ready to register the response callback.
- Call onEntityDiscovered() for each entity from DtWebServerObjectList::addedObjects().
- Call tick() once per VRF update tick from the VRF update thread.
- 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.
- Parameters
-
| trackedObjects | The live object registry owned by DtVrfManager. Must outlive this instance. |
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.
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.
| 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 |
| 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: