Use epicsGuard and epicsGuardRelease

These objects provide exception-safe locking and unlocking.
This commit is contained in:
Andrew Johnson
2016-01-22 12:05:23 -06:00
parent 61c41ceb7e
commit 6c08a05b81
4 changed files with 202 additions and 326 deletions

View File

@@ -11,6 +11,7 @@
#include <sstream>
#include <epicsGuard.h>
#include <pv/thread.h>
#include <pv/bitSetUtil.h>
#include <pv/queue.h>
@@ -144,21 +145,16 @@ Status MonitorLocal::start()
if(state==active) return alreadyStartedStatus;
}
pvRecord->addListener(getPtrSelf(),pvCopy);
pvRecord->lock();
try {
Lock xx(mutex);
state = active;
queue->clear();
isGroupPut = false;
activeElement = queue->getFree();
activeElement->changedBitSet->clear();
activeElement->overrunBitSet->clear();
activeElement->changedBitSet->set(0);
releaseActiveElement();
pvRecord->unlock();
} catch(...) {
pvRecord->unlock();
}
epicsGuard <PVRecord> guard(*pvRecord);
Lock xx(mutex);
state = active;
queue->clear();
isGroupPut = false;
activeElement = queue->getFree();
activeElement->changedBitSet->clear();
activeElement->overrunBitSet->clear();
activeElement->changedBitSet->set(0);
releaseActiveElement();
return Status::Ok;
}