[LAD] Inter thread Communication: Design Approach

Fons Adriaensen fons at linuxaudio.org
Fri Sep 2 10:04:05 UTC 2011


On Thu, Sep 01, 2011 at 03:54:03PM -0400, Paul Davis wrote:
> On Thu, Sep 1, 2011 at 2:37 PM, Fons Adriaensen <fons at linuxaudio.org> wrote:
> 
> > That's assuming that the event's virtual execute() has access to
> > all it needs. In all cases I've encountered that is not the case:
> > the event triggers something in the context where it is received
> > and processing it requires access to that context's data.
> > It's a problem for which I don't know a clean C++ solution.
> 
> depending on the exact type of thing you're talking about, isn't this
> is place for closures, functors, etc. etc. ?

Yes, but 

1. I find functor syntax extremely clumsy, involving the creation of
   a specific derived functor class (from a template class) for each
   one you need.

2. AFAIK (using the terminology of <http://www.newty.de/fpt/functor.html>,
   you can't have a TSpecificFunctor member in the event class and 
   initialise it, it has to be a TSpecificFunctor*. Which in turn
   means that at the sender side you either have instances of all
   possibly required functor classes available and assign the
   TSpecificFunctor* in the event from one of them, or you have to
   use new() to allocate one. The former is extremely clumsy, and
   the latter shouldn't be done in a RT context.

What I'm missing in C++ is a built-in 'functor' type that can
simply be assigned from any object::method, with the user being
responsible for the existence of the object and for supplying the
right arguments at the time the functor is called.


Ciao,

-- 
FA
  




More information about the Linux-audio-dev mailing list