[LAD] Inter thread Communication: Design Approach

Fons Adriaensen fons at linuxaudio.org
Sat Sep 3 21:25:22 UTC 2011


On Fri, Sep 02, 2011 at 07:50:17AM -0400, Paul Davis wrote:

> i'm pretty confused by what you've written here. i use functors which
> have copy semantics, and the "event" classes that contain a functor do
> not contain a pointer to a functor, but a functor that is copied. this
> is the base class:
> 
> 	struct BaseRequestObject {
> 	    RequestType             type;
>             bool                    valid;
>             InvalidationRecord*     invalidation;
> 	    boost::function<void()> the_slot;
> 
>             BaseRequestObject() : valid (true), invalidation (0) {}
> 	};
> 
> the "type" member is still there, but differentiates between requests
> that require use of the functor ("the_slot") and those that are just
> an enum that can be handled with no data (e.g. telling an event
> loop/thread to quit).

Mmm. Did you ever look at what's going on behind the scenes
(/usr/include/boost/function/function/function_base.hpp) ?

Calling a void function(void) is a basic language operation,
supported directly by most CPU instruction sets and normally
translating into just a few CPU instrunctions. If doing this
requires > 900 lines of code (plus all the files included from
the one referred to) I'd say there is something fundamentally
wrong. Even emulating a function call on a different CPU or 
a virtual one doesn't take anything like that.

Ciao,

-- 
FA




More information about the Linux-audio-dev mailing list