use weak pointer for callbacks

This commit is contained in:
mrkraimer
2016-01-07 07:44:08 -05:00
parent ca3573291a
commit 4ac867ec0f
8 changed files with 188 additions and 96 deletions

View File

@@ -26,6 +26,7 @@
#include <epicsThread.h>
#include <iocsh.h>
#include <shareLib.h>
#include <epicsExit.h>
#include <pv/pvAccess.h>
#include <pv/serverContext.h>
@@ -52,6 +53,9 @@ extern "C" void pvdbl(const iocshArgBuf *args)
for(size_t i=0; i<xxx.size(); ++i) cout<< xxx[i] << endl;
}
static void channelProviderLocalExitHandler(void* /*pPrivate*/) {
getChannelProviderLocal()->destroy();
}
static void registerChannelProviderLocal(void)
{
@@ -60,6 +64,7 @@ static void registerChannelProviderLocal(void)
firstTime = 0;
iocshRegister(&pvdblFuncDef, pvdbl);
getChannelProviderLocal();
epicsAtExit(channelProviderLocalExitHandler, NULL);
}
}