Experimental Physics and Industrial Control System
Hi Mark,
My understanding is that the destructor (dtor) won't be called because the objects are allocated on the heap not on the stack so they won't go out of scope. Here is the simDetector allocation for example:
/** Configuration command, called directly or from iocsh */
extern "C" int simDetectorConfig(const char *portName, int maxSizeX, int maxSizeY, int dataType,
int maxBuffers, int maxMemory, int priority, int stackSize)
{
new simDetector(portName, maxSizeX, maxSizeY, (NDDataType_t)dataType,
(maxBuffers < 0) ? 0 : maxBuffers,
(maxMemory < 0) ? 0 : maxMemory,
priority, stackSize);
return(asynSuccess);
}
Currently if you want to run the dtor you need to establish an exit handler, typically with epicsAtExit().
Perhaps the base class (asynPortDriver?) should establish an exit handler in its ctor and call the dtor for you? If we did that and the derived class also has an exit handler then the derived class exit handler will be called first. How does the base class then determine that the dtor has already been called and the pointer it receives in the exit handler callback is no longer valid?
Mark
________________________________
From: Mark Engbretson <[email protected]>
Sent: Tuesday, December 12, 2017 10:08 AM
To: Mark Rivers
Cc: 'EPICS tech-talk'
Subject: Area Detector Destructors
Mark -
Should destructors be being called when Area Detectors shutdown (I don't seem to see that happening) or do you have to do what a few AD's have done and create an exit handler if you need to perform any sort of cleanup.
I have a camera with a FPGA which runs *hot* when it is being used, so shutting it down when the AD exits or aborts might prevent it from baking itself. Trace code never seems to be hit in the destructor.
- References:
- Area Detector Destructors Mark Engbretson
- Navigate by Date:
- Prev:
Area Detector Destructors Mark Engbretson
- Next:
Touch panel pc to operator console yak man
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
<2017>
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Area Detector Destructors Mark Engbretson
- Next:
Touch panel pc to operator console yak man
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
<2017>
2018
2019
2020
2021
2022
2023
2024