EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <20172018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <20172018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Area Detector Destructors
From: Mark Rivers <[email protected]>
To: Mark Engbretson <[email protected]>
Cc: 'EPICS tech-talk' <[email protected]>
Date: Tue, 12 Dec 2017 23:31:02 +0000
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  <20172018  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  <20172018  2019  2020  2021  2022  2023  2024 
ANJ, 21 Dec 2017 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·