Use epicsMutex and epicsEvent instead of pv::data equivalents

This commit is contained in:
Andrew Johnson
2020-12-04 12:30:21 -06:00
committed by mdavidsaver
parent 0332d0f2c1
commit 98e81a542e
8 changed files with 46 additions and 44 deletions

View File

@@ -7,14 +7,13 @@
#include <iostream>
#include <queue>
#include <epicsThread.h>
#include <pv/event.h>
#include <pv/lock.h>
#include <epicsMutex.h>
#include <epicsEvent.h>
#include <pv/sharedPtr.h>
#define epicsExportSharedSymbols
#include "notifierConveyor.h"
using epics::pvData::Lock;
namespace epics {
namespace pvAccess {
namespace ca {
@@ -23,10 +22,10 @@ NotifierConveyor::~NotifierConveyor()
{
if (thread) {
{
Lock the(mutex);
epicsGuard<epicsMutex> G(mutex);
halt = true;
}
workToDo.signal();
workToDo.trigger();
thread->exitWait();
}
}
@@ -45,12 +44,12 @@ void NotifierConveyor::notifyClient(
NotificationPtr const &notificationPtr)
{
{
Lock the(mutex);
epicsGuard<epicsMutex> G(mutex);
if (halt || notificationPtr->queued) return;
notificationPtr->queued = true;
workQueue.push(notificationPtr);
}
workToDo.signal();
workToDo.trigger();
}
void NotifierConveyor::run()
@@ -58,7 +57,7 @@ void NotifierConveyor::run()
bool stopping;
do {
workToDo.wait();
Lock the(mutex);
epicsGuard<epicsMutex> G(mutex);
stopping = halt;
while (!stopping && !workQueue.empty())
{
@@ -69,7 +68,7 @@ void NotifierConveyor::run()
notification->queued = false;
NotifierClientPtr client(notification->client.lock());
if (client) {
the.unlock();
epicsGuardRelease<epicsMutex> U(G);
try { client->notifyClient(); }
catch (std::exception &e) {
std::cerr << "Exception from notifyClient(): "
@@ -79,7 +78,6 @@ void NotifierConveyor::run()
std::cerr << "Unknown exception from notifyClient()"
<< std::endl;
}
the.lock();
}
stopping = halt;
// client's destructor may run here, could delete *this