##// END OF EJS Templates
Fix lock bug
perrinel -
r814:baf81ae414e4
parent child
Show More
@@ -96,14 +96,13 QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid v
96 auto oldAcqRequest = acqIdentifierToAcqRequestMapIt->second;
96 auto oldAcqRequest = acqIdentifierToAcqRequestMapIt->second;
97 varRequestIdCanceled = oldAcqRequest.m_VarRequestId;
97 varRequestIdCanceled = oldAcqRequest.m_VarRequestId;
98 }
98 }
99 // remove old acqIdentifier from the worker
100 impl->cancelVarRequest(oldAcqId);
101 // impl->m_AcqIdentifierToAcqRequestMap.erase(oldAcqId);
102
99
103 it->second.second = acqRequest.m_AcqIdentifier;
100 it->second.second = acqRequest.m_AcqIdentifier;
104
105
106 impl->unlock();
101 impl->unlock();
102
103 // remove old acqIdentifier from the worker
104 impl->cancelVarRequest(oldAcqId);
105 // impl->m_AcqIdentifierToAcqRequestMap.erase(oldAcqId);
107 }
106 }
108 else {
107 else {
109 // First request for the variable, it must be stored and executed
108 // First request for the variable, it must be stored and executed
@@ -344,6 +343,7 void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::updateToNextRe
344 void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::cancelVarRequest(
343 void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::cancelVarRequest(
345 QUuid varRequestId)
344 QUuid varRequestId)
346 {
345 {
346 qInfo() << "VariableAcquisitionWorkerPrivate::cancelVarRequest 0";
347 lockRead();
347 lockRead();
348 // get all AcqIdentifier in link with varRequestId
348 // get all AcqIdentifier in link with varRequestId
349 QVector<QUuid> acqIdsToRm;
349 QVector<QUuid> acqIdsToRm;
@@ -359,23 +359,29 void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::cancelVarReque
359 for (auto acqId : acqIdsToRm) {
359 for (auto acqId : acqIdsToRm) {
360 removeAcqRequest(acqId);
360 removeAcqRequest(acqId);
361 }
361 }
362 qInfo() << "VariableAcquisitionWorkerPrivate::cancelVarRequest end";
362 }
363 }
363
364
364 void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::removeAcqRequest(
365 void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::removeAcqRequest(
365 QUuid acqRequestId)
366 QUuid acqRequestId)
366 {
367 {
368 qInfo() << "VariableAcquisitionWorkerPrivate::removeAcqRequest 0";
367 QUuid vIdentifier;
369 QUuid vIdentifier;
368 std::shared_ptr<IDataProvider> provider;
370 std::shared_ptr<IDataProvider> provider;
369 lockRead();
371 lockRead();
370 auto acqIt = m_AcqIdentifierToAcqRequestMap.find(acqRequestId);
372 auto acqIt = m_AcqIdentifierToAcqRequestMap.find(acqRequestId);
373 qInfo() << "VariableAcquisitionWorkerPrivate::removeAcqRequest 1";
371 if (acqIt != m_AcqIdentifierToAcqRequestMap.cend()) {
374 if (acqIt != m_AcqIdentifierToAcqRequestMap.cend()) {
372 vIdentifier = acqIt->second.m_vIdentifier;
375 vIdentifier = acqIt->second.m_vIdentifier;
373 provider = acqIt->second.m_Provider;
376 provider = acqIt->second.m_Provider;
374
377
378 qInfo() << "VariableAcquisitionWorkerPrivate::removeAcqRequest 2";
375 auto it = m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(vIdentifier);
379 auto it = m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(vIdentifier);
376 if (it != m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) {
380 if (it != m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) {
381 qInfo() << "VariableAcquisitionWorkerPrivate::removeAcqRequest 3";
377 if (it->second.first == acqRequestId) {
382 if (it->second.first == acqRequestId) {
378 // acqRequest is currently running -> let's aborting it
383 // acqRequest is currently running -> let's aborting it
384 qInfo() << "VariableAcquisitionWorkerPrivate::removeAcqRequest 4";
379 unlock();
385 unlock();
380
386
381 // Remove the current request from the worker
387 // Remove the current request from the worker
@@ -383,27 +389,34 void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::removeAcqReque
383
389
384 // notify the request aborting to the provider
390 // notify the request aborting to the provider
385 provider->requestDataAborting(acqRequestId);
391 provider->requestDataAborting(acqRequestId);
392 qInfo() << "VariableAcquisitionWorkerPrivate::removeAcqRequest 5";
386 }
393 }
387 else if (it->second.second == acqRequestId) {
394 else if (it->second.second == acqRequestId) {
388 it->second.second = QUuid();
395 it->second.second = QUuid();
396 qInfo() << "VariableAcquisitionWorkerPrivate::removeAcqRequest 6";
389 unlock();
397 unlock();
390 }
398 }
391 else {
399 else {
400 qInfo() << "VariableAcquisitionWorkerPrivate::removeAcqRequest 7";
392 unlock();
401 unlock();
393 }
402 }
394 }
403 }
395 else {
404 else {
405 qInfo() << "VariableAcquisitionWorkerPrivate::removeAcqRequest 8";
396 unlock();
406 unlock();
397 }
407 }
398 }
408 }
399 else {
409 else {
410 qInfo() << "VariableAcquisitionWorkerPrivate::removeAcqRequest 9";
400 unlock();
411 unlock();
401 }
412 }
402
413
414 qInfo() << "VariableAcquisitionWorkerPrivate::removeAcqRequest 10";
403 lockWrite();
415 lockWrite();
404
416
405 m_AcqIdentifierToAcqDataPacketVectorMap.erase(acqRequestId);
417 m_AcqIdentifierToAcqDataPacketVectorMap.erase(acqRequestId);
406 m_AcqIdentifierToAcqRequestMap.erase(acqRequestId);
418 m_AcqIdentifierToAcqRequestMap.erase(acqRequestId);
407
419
408 unlock();
420 unlock();
421 qInfo() << "VariableAcquisitionWorkerPrivate::removeAcqRequest 11";
409 }
422 }
General Comments 0
You need to be logged in to leave comments. Login now