Commit aa6baac9 authored by Marc R.'s avatar Marc R.

trajectory actor: fix bug that caused sync control to stall if multiple seed...

trajectory actor: fix bug that caused sync control to stall if multiple seed actors are present for trajectory computation
parent dc85310a
......@@ -67,6 +67,7 @@ namespace Met3D
: MActor(),
MBoundingBoxInterface(this, MBoundingBoxConnectionType::HORIZONTAL),
......@@ -1497,10 +1498,17 @@ void MTrajectoryActor::prepareAvailableDataForRendering(uint slot)
// If this was a synchronization request signal to the sync control
// that it has been completed.
// If this was a synchronization request, check if the request was
// the last request due to the sync sent by any seed actor -- if
// yes, signal to the sync control that the sync has been completed.
if (trqi.syncchronizationRequest)
numSeedActorsForRequestEvent[trqi.requestID] -= 1;
if (numSeedActorsForRequestEvent[trqi.requestID] == 0)
......@@ -2824,6 +2832,22 @@ void MTrajectoryActor::asynchronousDataRequest(bool synchronizationRequest)
unsigned int requestID = ++globalRequestIDCounter;
if (synchronizationRequest)
// Due to the current implementation of having multiple request queues
// for multiple seed actors, we need to keep track of how many
// requests have been sent for a given sync event. For this, each
// request is assigned a unique "request ID"; the map
// "numSeedActorsForRequestEvent" stores how many "seed actors" have
// caused requests. In prepareAvailableDataForRendering(), this
// counter is checked before the "sync completed" signal is sent
// to the sync control.
//NOTE (mr, 28Aug2018) -- a better way to implement this would probably be to
// signal back to the sync control //which// sync signal has been completed...
numSeedActorsForRequestEvent.insert(requestID, 0);
for (int t = 0; t < (precomputedDataSource ? 1 : seedActorData.size()); t++)
......@@ -2839,6 +2863,11 @@ void MTrajectoryActor::asynchronousDataRequest(bool synchronizationRequest)
trqi.numPendingRequests = 0;
trqi.syncchronizationRequest = synchronizationRequest;
trqi.requestID = requestID;
if (synchronizationRequest)
numSeedActorsForRequestEvent[requestID] += 1;
// Request 1: Trajectories for the current time and ensemble settings.
......@@ -334,6 +334,7 @@ private:
int numPendingRequests;
bool syncchronizationRequest;
unsigned int requestID;
......@@ -359,6 +360,12 @@ private:
QVector<MTrajectoryRequestBuffer> trajectoryRequests;
/** Counter to keep track of requests for correct handling of sync
events with multiple seed actors present. See comment in
asynchronousDataRequest(). */
unsigned int globalRequestIDCounter;
QMap<unsigned int, unsigned int> numSeedActorsForRequestEvent;
MTrajectoryDataSource *trajectorySource;
MTrajectories *trajectories;
GL::MVertexBuffer *trajectoriesVertexBuffer;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment