[LAD] Inter thread Communication: Design Approach

Paul Davis paul at linuxaudiosystems.com
Sun Sep 4 00:42:29 UTC 2011


On Sat, Sep 3, 2011 at 5:25 PM, Fons Adriaensen <fons at linuxaudio.org> wrote:
> 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.

this is a complete diversion from the point i was making.

if the functor has copy semantics, its not true that you must have a
pointer to the functor in an event/request structure.

the issues with the performance of boost::function are reasonably well
known and were well documented in the article that florian linked to,
along with a much better performing drop-in replacement.



More information about the Linux-audio-dev mailing list