Am 08.11.2016 um 14:08 schrieb Mark Rivers:
> Actually I think you need to call start() in the code that created
> the object, not in the constructor. The problem is that the derived
> class needs to be completely constructed before start() is called.
Am 08.11.2016 um 18:14 schrieb Mark Rivers:
>> What was causing the problem with this being handled in the base
>> class as before?
>
> The start() method was added in R2-5. The problem was race
> conditions that were discovered when running the unit tests in the
> pluginTest directory. Those tests instantiate drivers and plugins
> that only exist for a very short amount of time. As I recall the
> problems were one or more of the following:
>
> - The first callback occurred before the thread that processes the
> plugins had started running. The callbacks can start as soon as the
> base class constructor is called.
>
> - The first callback occurred before the derived class constructor
> was complete. In this case the base class processCallbacks method
> will be called, not the derived class method, which is not what is
> intended.
>
> - The destructor was called before the thread had a chance to process
> the callback.
>
> To fix these problems the start() method was added, and it must be
> called by the code that instantiates the plugin.
These problems are symptoms of a disease that goes deeper and is more
general. Indeed, subclassing is not (and cannot easily be made) aware of
complex initialization protocols. This is a fundamental shortcoming of
the OO paradigm and one of the reasons why APIs that require the user to
derive subclasses are difficult to use correctly. The functional
approach is much more flexible here: instead of letting users derive
subclasses, you require the user's init function to be passed as a
parameter to the "base class" init function. The latter remains in
control of the overall initialization order; the protocol is
encapsulated and extensions cannot break it. This gives you an API that
is much easier to use.
Cheers
Ben
Attachment:
signature.asc
Description: OpenPGP digital signature
- References:
- processCallbacks() never called in areaDetector plugin Jonas Nilsson
- Re: processCallbacks() never called in areaDetector plugin Siniša Veseli
- RE: processCallbacks() never called in areaDetector plugin Mark Rivers
- Re: processCallbacks() never called in areaDetector plugin Siniša Veseli
- RE: processCallbacks() never called in areaDetector plugin Mark Rivers
- Navigate by Date:
- Prev:
Re: EPICS Base Release-Candidate Double Feature! Ben Franksen
- Next:
Re: EPICS Base Release-Candidate Double Feature! Heinz Junkes
- 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:
RE: processCallbacks() never called in areaDetector plugin Mark Rivers
- Next:
Multiple NDPluginPva issues Alexander Söderqvist
- 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
|