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  <20132014  2015  2016  2017  2018  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  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Problem in errlogRemoveListener
From: Benjamin Franksen <[email protected]>
To: <[email protected]>
Date: Mon, 24 Jun 2013 16:14:38 +0200
Am Samstag, 22. Juni 2013, 00:01:34 schrieb Andrew Johnson:
> On 2013-06-21 Benjamin Franksen wrote:
> > Cool. However, for 3.15 I propose to change the existing
> >
> >  errlogRemoveListener, instead of adding a new function; I was
> >  speculating on the patch being accepted for 3.14.12.4, which is why I
> >  added a new function.
>
> I added the ability to delete multiple listeners, and it now returns a
> count of the number actually removed.
>
> This version (against 3.15) renames the function and adds a flags argument,
> but provides an API-compatible macro for code written against 3.14, plus
> some others to give it a simple API.
>
> Comments welcome.

Hi Andrew

your proposal tries to reify all the possible ways to compare two closures
(listener code + environment) as data. Another approach, which I personally
prefer, is to let users define their own matching criteria, i.e.

        typedef struct {
                void (*code)(char *,void*);
                void *env;
        } errlogListener;

        typedef int errlogMatchListener(errlogListener*, errlogListener*);

        void errlogAddListener(errlogListener *this);
        void errlogRemoveListeners(errlogListener *this, errlogMatchListener *eq);

with the informal spec

* errlogAddListener(this) stores its argument 'this' in the list

* errlogRemoveListeners(this,eq) removes all listeners 'l' for which

        eq(this,l)

  returns true (non-zero)

Note that this approach opens up the possibility to match using pointer
equality of the listener struct, which is not covered by your enumeration.

IMO, removing only the first matching list element is unsafe and should not be
supported. If a user has called errlogAddListener(l) with the "same" l
(according to some errlogMatchListener) more than once, removing it more than
once will do no harm (subsequent calls are just no-ops).

One or more pre-defined matchers can be supplied for convenience, similar as
in your proposal, possibly as static (i.e. inlinable) functions defined in the
header, e.g.

        static int errlogMatchListenerDefault(
                errlogListener *x, errlogListener *y)
        {
                return (x->code == y->code && x->env == y->env);
        }

I am willing to flesh out this proposal and send a patch if teh general idea
meets approval.

Cheers
--
Ben Franksen
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachm€nts

________________________________

Helmholtz-Zentrum Berlin für Materialien und Energie GmbH

Mitglied der Hermann von Helmholtz-Gemeinschaft Deutscher Forschungszentren e.V.

Aufsichtsrat: Vorsitzender Prof. Dr. Dr. h.c. mult. Joachim Treusch, stv. Vorsitzende Dr. Beatrix Vierkorn-Rudolph
Geschäftsführung: Prof. Dr. Anke Rita Kaysser-Pyzalla, Thomas Frederking

Sitz Berlin, AG Charlottenburg, 89 HRB 5583

Postadresse:
Hahn-Meitner-Platz 1
D-14109 Berlin

http://www.helmholtz-berlin.de


Replies:
Re: Problem in errlogRemoveListener Andrew Johnson
References:
Re: Problem in errlogRemoveListener Andrew Johnson

Navigate by Date:
Prev: Re: VAL field of PV in ASYN driver Vishnu Patel
Next: Re: Problem in errlogRemoveListener Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Problem in errlogRemoveListener Andrew Johnson
Next: Re: Problem in errlogRemoveListener Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 20 Apr 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·