[Bug 1673] Chain append and prepend with empty check

bugzilla-daemon at rtems.org bugzilla-daemon at rtems.org
Wed Aug 18 06:31:07 UTC 2010


https://www.rtems.org/bugzilla/show_bug.cgi?id=1673

--- Comment #5 from Sebastian Huber <sebastian.huber at embedded-brains.de> 2010-08-18 01:31:06 CDT ---
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #2)
> > > Additionaly I think API calls along the line:
> > > 
> > > rtems_chain_get_with_empty_check() ...
> > 
> > Do we really need this? chain_get() already returns NULL if the chain is empty.
> 
> But I had a different application in mind: notify a producer if you took the
> last one from the chain.
> So the empty check would be after the last one was taken.

I didn't think about multiple consumers.  With at most one consumer we don't
have race conditions here with the standard chain_get().  You notify the
producer if the chain is empty.  With multiple consumers you need the
chain_get_with_empty_check().

> With chain_get there is the question of what is returned.
> 
> Because  of this it might even make sense to have the 
> 
> rtems_chain_append_with_notification( chain, node, tid, event) 
> 
> and
> 
> rtems_chain_get_with_notification (chain, tid, event)  -> node
> 
> functions instead.  These were the functions Joel suggested to me in IRC. 
> Their disadvantage are of course that in theory they are less flexible.  But in
> practice they encapsulate a very common use case.

In case of get we yield nothing here regarding the return value problem since
we have to return a status code from the notification functions
(rtems_event_send() may fail).

-- 
Configure bugmail: https://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the bugs mailing list