AsyncUpdater with arguments


#1

Usage

#include "StandardHeader.h" // juce
#include "AsyncUpdater.h"

typedef swissarmyknife::AsyncUpdater2<int, float> MyAsyncUpdater;
typedef swissarmyknife::AsyncUpdater4<char, char, char, bool> MyOtherAsyncUpdater:

class MyClass : public MyAsyncUpdater,
                public MyOtherAsyncUpdater
{
public:
    using MyAsyncUpdater::triggerAsyncUpdate;
    using MyOtherAsyncUpdater::triggerAsyncUpdate;

    void handleAsyncUpdate(int arg1, float arg2)
    {
        // do your handle here !
    }

    void handleAsyncUpdate(char arg1, char arg2, char arg3, bool arg4)
    {
        // do your handle here !
    }
};

void supernaturalFunction()
{
    MyClass a;

    a.triggerAsyncUpdate(1, 1.0f);

    a.triggerAsyncUpdate(1, 2, 3, false);
}

AsyncUpdater.h

/*
 * AsyncUpdater
 *
 * Copyright (c) 2015 Lucio Asnaghi
 * 
 */

#ifndef AsyncUpdater_h
#define AsyncUpdater_h

namespace swissarmyknife {

#include "AsyncUpdaterList.h"

} // end namespace

#endif // AsyncUpdater_h

AsyncUpdaterTemplate.h

/*
 * AsyncUpdater
 *
 * Copyright (c) 2015 Lucio Asnaghi
 * 
 */
#define ASYNCUPDATER_JOIN_MACRO( X, Y) ASYNCUPDATER_DO_JOIN( X, Y )
#define ASYNCUPDATER_DO_JOIN( X, Y ) ASYNCUPDATER_DO_JOIN2(X,Y)
#define ASYNCUPDATER_DO_JOIN2( X, Y ) X##Y

#define ASYNCUPDATER_CLASS_NAME ASYNCUPDATER_JOIN_MACRO(AsyncUpdater, ASYNCUPDATER_PARAM_COUNT)
#define ASYNCUPDATER_MESSAGE_CLASS_NAME ASYNCUPDATER_JOIN_MACRO(AsyncUpdaterMessage, ASYNCUPDATER_PARAM_COUNT)

#if ASYNCUPDATER_PARAM_COUNT > 0
    template <ASYNCUPDATER_TEMPLATE_PARAMS>
#endif
    class ASYNCUPDATER_CLASS_NAME
{
public:
    ASYNCUPDATER_CLASS_NAME()
    {
        activeMessage = new ASYNCUPDATER_MESSAGE_CLASS_NAME
#if ASYNCUPDATER_PARAM_COUNT > 0
            <ASYNCUPDATER_TEMPLATE_ARGS>
#endif
        (*this);
    }

    virtual ~ASYNCUPDATER_CLASS_NAME()
    {
        // You're deleting this object with a background thread while there's an update
        // pending on the main event thread - that's pretty dodgy threading, as the callback could
        // happen after this destructor has finished. You should either use a MessageManagerLock while
        // deleting this object, or find some other way to avoid such a race condition.
        jassert ((! isUpdatePending()) || juce::MessageManager::getInstance()->currentThreadHasLockedMessageManager());

        activeMessage->shouldDeliver.set (0);
    }

    void triggerAsyncUpdate(ASYNCUPDATER_PARAMS)
    {
        if (activeMessage->shouldDeliver.compareAndSetBool (1, 0))
        {
#if ASYNCUPDATER_PARAM_COUNT > 0
            activeMessage->setArguments(ASYNCUPDATER_ARGS);
#endif

            if (! activeMessage->post())
                cancelPendingUpdate(); // if the message queue fails, this avoids getting
                                       // trapped waiting for the message to arrive
        }
    }

    void cancelPendingUpdate() noexcept
    {
        activeMessage->shouldDeliver.set (0);
    }

    void handleUpdateNowIfNeeded()
    {
        // This can only be called by the event thread.
        jassert (juce::MessageManager::getInstance()->currentThreadHasLockedMessageManager());

        if (activeMessage->shouldDeliver.exchange (0) != 0)
        {
            handleAsyncUpdate(ASYNCUPDATER_MESSAGE_CALL_ARGS);
        }
    }

    bool isUpdatePending() const noexcept
    {
        return activeMessage->shouldDeliver.value != 0;
    }

    virtual void handleAsyncUpdate(ASYNCUPDATER_PARAMS) = 0;

private:
#if ASYNCUPDATER_PARAM_COUNT > 0
    template <ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS>
#endif
    class ASYNCUPDATER_MESSAGE_CLASS_NAME
        : public juce::CallbackMessage
    {
    public:
        ASYNCUPDATER_MESSAGE_CLASS_NAME(ASYNCUPDATER_CLASS_NAME
#if ASYNCUPDATER_PARAM_COUNT > 0
            <ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS>
#endif
            & au) : owner (au) {}

        void setArguments(ASYNCUPDATER_MESSAGE_PARAMS)
        {
            ASYNCUPDATER_MESSAGE_SET_DATA
        }

        void messageCallback() override
        {
            if (shouldDeliver.compareAndSetBool (0, 1))
                owner.handleAsyncUpdate(ASYNCUPDATER_MESSAGE_ARGS);
        }

        juce::Atomic<int> shouldDeliver;
        ASYNCUPDATER_MESSAGE_DATA

    private:
        ASYNCUPDATER_CLASS_NAME
#if ASYNCUPDATER_PARAM_COUNT > 0
            <ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS>
#endif
         & owner;

        JUCE_DECLARE_NON_COPYABLE (ASYNCUPDATER_MESSAGE_CLASS_NAME)
    };

#if ASYNCUPDATER_PARAM_COUNT > 0
    friend class juce::ReferenceCountedObjectPtr< ASYNCUPDATER_MESSAGE_CLASS_NAME<ASYNCUPDATER_TEMPLATE_ARGS> >;
    juce::ReferenceCountedObjectPtr< ASYNCUPDATER_MESSAGE_CLASS_NAME<ASYNCUPDATER_TEMPLATE_ARGS> > activeMessage;
#else
    friend class juce::ReferenceCountedObjectPtr< ASYNCUPDATER_MESSAGE_CLASS_NAME >;
    juce::ReferenceCountedObjectPtr< ASYNCUPDATER_MESSAGE_CLASS_NAME > activeMessage;
#endif

    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ASYNCUPDATER_CLASS_NAME)
};

#undef ASYNCUPDATER_MESSAGE_CLASS_NAME
#undef ASYNCUPDATER_CLASS_NAME
#undef ASYNCUPDATER_JOIN_MACRO
#undef ASYNCUPDATER_DO_JOIN
#undef ASYNCUPDATER_DO_JOIN2

AsyncUpdaterList.h

// Automaticly generaged by rebuild_asyncupdater_list.pl

// 0 params
#define ASYNCUPDATER_PARAM_COUNT 0
#define ASYNCUPDATER_TEMPLATE_PARAMS 
#define ASYNCUPDATER_TEMPLATE_ARGS 
#define ASYNCUPDATER_PARAMS 
#define ASYNCUPDATER_ARGS 
#define ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS 
#define ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS 
#define ASYNCUPDATER_MESSAGE_PARAMS 
#define ASYNCUPDATER_MESSAGE_ARGS 
#define ASYNCUPDATER_MESSAGE_CALL_ARGS 
#define ASYNCUPDATER_MESSAGE_SET_DATA 
#define ASYNCUPDATER_MESSAGE_DATA 
#include "AsyncUpdaterTemplate.h"
#undef ASYNCUPDATER_PARAM_COUNT
#undef ASYNCUPDATER_TEMPLATE_PARAMS
#undef ASYNCUPDATER_TEMPLATE_ARGS
#undef ASYNCUPDATER_PARAMS
#undef ASYNCUPDATER_ARGS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS
#undef ASYNCUPDATER_MESSAGE_PARAMS
#undef ASYNCUPDATER_MESSAGE_ARGS
#undef ASYNCUPDATER_MESSAGE_CALL_ARGS
#undef ASYNCUPDATER_MESSAGE_SET_DATA
#undef ASYNCUPDATER_MESSAGE_DATA

// 1 params
#define ASYNCUPDATER_PARAM_COUNT 1
#define ASYNCUPDATER_TEMPLATE_PARAMS typename A1
#define ASYNCUPDATER_TEMPLATE_ARGS A1
#define ASYNCUPDATER_PARAMS A1 a1
#define ASYNCUPDATER_ARGS a1
#define ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS typename B1
#define ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS B1
#define ASYNCUPDATER_MESSAGE_PARAMS B1 b1
#define ASYNCUPDATER_MESSAGE_ARGS b1
#define ASYNCUPDATER_MESSAGE_CALL_ARGS activeMessage->b1
#define ASYNCUPDATER_MESSAGE_SET_DATA b1 = b1; 
#define ASYNCUPDATER_MESSAGE_DATA B1 b1; 
#include "AsyncUpdaterTemplate.h"
#undef ASYNCUPDATER_PARAM_COUNT
#undef ASYNCUPDATER_TEMPLATE_PARAMS
#undef ASYNCUPDATER_TEMPLATE_ARGS
#undef ASYNCUPDATER_PARAMS
#undef ASYNCUPDATER_ARGS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS
#undef ASYNCUPDATER_MESSAGE_PARAMS
#undef ASYNCUPDATER_MESSAGE_ARGS
#undef ASYNCUPDATER_MESSAGE_CALL_ARGS
#undef ASYNCUPDATER_MESSAGE_SET_DATA
#undef ASYNCUPDATER_MESSAGE_DATA

// 2 params
#define ASYNCUPDATER_PARAM_COUNT 2
#define ASYNCUPDATER_TEMPLATE_PARAMS typename A1, typename A2
#define ASYNCUPDATER_TEMPLATE_ARGS A1, A2
#define ASYNCUPDATER_PARAMS A1 a1, A2 a2
#define ASYNCUPDATER_ARGS a1, a2
#define ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS typename B1, typename B2
#define ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS B1, B2
#define ASYNCUPDATER_MESSAGE_PARAMS B1 b1, B2 b2
#define ASYNCUPDATER_MESSAGE_ARGS b1, b2
#define ASYNCUPDATER_MESSAGE_CALL_ARGS activeMessage->b1, activeMessage->b2
#define ASYNCUPDATER_MESSAGE_SET_DATA b1 = b1; b2 = b2; 
#define ASYNCUPDATER_MESSAGE_DATA B1 b1; B2 b2; 
#include "AsyncUpdaterTemplate.h"
#undef ASYNCUPDATER_PARAM_COUNT
#undef ASYNCUPDATER_TEMPLATE_PARAMS
#undef ASYNCUPDATER_TEMPLATE_ARGS
#undef ASYNCUPDATER_PARAMS
#undef ASYNCUPDATER_ARGS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS
#undef ASYNCUPDATER_MESSAGE_PARAMS
#undef ASYNCUPDATER_MESSAGE_ARGS
#undef ASYNCUPDATER_MESSAGE_CALL_ARGS
#undef ASYNCUPDATER_MESSAGE_SET_DATA
#undef ASYNCUPDATER_MESSAGE_DATA

// 3 params
#define ASYNCUPDATER_PARAM_COUNT 3
#define ASYNCUPDATER_TEMPLATE_PARAMS typename A1, typename A2, typename A3
#define ASYNCUPDATER_TEMPLATE_ARGS A1, A2, A3
#define ASYNCUPDATER_PARAMS A1 a1, A2 a2, A3 a3
#define ASYNCUPDATER_ARGS a1, a2, a3
#define ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS typename B1, typename B2, typename B3
#define ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS B1, B2, B3
#define ASYNCUPDATER_MESSAGE_PARAMS B1 b1, B2 b2, B3 b3
#define ASYNCUPDATER_MESSAGE_ARGS b1, b2, b3
#define ASYNCUPDATER_MESSAGE_CALL_ARGS activeMessage->b1, activeMessage->b2, activeMessage->b3
#define ASYNCUPDATER_MESSAGE_SET_DATA b1 = b1; b2 = b2; b3 = b3; 
#define ASYNCUPDATER_MESSAGE_DATA B1 b1; B2 b2; B3 b3; 
#include "AsyncUpdaterTemplate.h"
#undef ASYNCUPDATER_PARAM_COUNT
#undef ASYNCUPDATER_TEMPLATE_PARAMS
#undef ASYNCUPDATER_TEMPLATE_ARGS
#undef ASYNCUPDATER_PARAMS
#undef ASYNCUPDATER_ARGS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS
#undef ASYNCUPDATER_MESSAGE_PARAMS
#undef ASYNCUPDATER_MESSAGE_ARGS
#undef ASYNCUPDATER_MESSAGE_CALL_ARGS
#undef ASYNCUPDATER_MESSAGE_SET_DATA
#undef ASYNCUPDATER_MESSAGE_DATA

// 4 params
#define ASYNCUPDATER_PARAM_COUNT 4
#define ASYNCUPDATER_TEMPLATE_PARAMS typename A1, typename A2, typename A3, typename A4
#define ASYNCUPDATER_TEMPLATE_ARGS A1, A2, A3, A4
#define ASYNCUPDATER_PARAMS A1 a1, A2 a2, A3 a3, A4 a4
#define ASYNCUPDATER_ARGS a1, a2, a3, a4
#define ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS typename B1, typename B2, typename B3, typename B4
#define ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS B1, B2, B3, B4
#define ASYNCUPDATER_MESSAGE_PARAMS B1 b1, B2 b2, B3 b3, B4 b4
#define ASYNCUPDATER_MESSAGE_ARGS b1, b2, b3, b4
#define ASYNCUPDATER_MESSAGE_CALL_ARGS activeMessage->b1, activeMessage->b2, activeMessage->b3, activeMessage->b4
#define ASYNCUPDATER_MESSAGE_SET_DATA b1 = b1; b2 = b2; b3 = b3; b4 = b4; 
#define ASYNCUPDATER_MESSAGE_DATA B1 b1; B2 b2; B3 b3; B4 b4; 
#include "AsyncUpdaterTemplate.h"
#undef ASYNCUPDATER_PARAM_COUNT
#undef ASYNCUPDATER_TEMPLATE_PARAMS
#undef ASYNCUPDATER_TEMPLATE_ARGS
#undef ASYNCUPDATER_PARAMS
#undef ASYNCUPDATER_ARGS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS
#undef ASYNCUPDATER_MESSAGE_PARAMS
#undef ASYNCUPDATER_MESSAGE_ARGS
#undef ASYNCUPDATER_MESSAGE_CALL_ARGS
#undef ASYNCUPDATER_MESSAGE_SET_DATA
#undef ASYNCUPDATER_MESSAGE_DATA

// 5 params
#define ASYNCUPDATER_PARAM_COUNT 5
#define ASYNCUPDATER_TEMPLATE_PARAMS typename A1, typename A2, typename A3, typename A4, typename A5
#define ASYNCUPDATER_TEMPLATE_ARGS A1, A2, A3, A4, A5
#define ASYNCUPDATER_PARAMS A1 a1, A2 a2, A3 a3, A4 a4, A5 a5
#define ASYNCUPDATER_ARGS a1, a2, a3, a4, a5
#define ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS typename B1, typename B2, typename B3, typename B4, typename B5
#define ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS B1, B2, B3, B4, B5
#define ASYNCUPDATER_MESSAGE_PARAMS B1 b1, B2 b2, B3 b3, B4 b4, B5 b5
#define ASYNCUPDATER_MESSAGE_ARGS b1, b2, b3, b4, b5
#define ASYNCUPDATER_MESSAGE_CALL_ARGS activeMessage->b1, activeMessage->b2, activeMessage->b3, activeMessage->b4, activeMessage->b5
#define ASYNCUPDATER_MESSAGE_SET_DATA b1 = b1; b2 = b2; b3 = b3; b4 = b4; b5 = b5; 
#define ASYNCUPDATER_MESSAGE_DATA B1 b1; B2 b2; B3 b3; B4 b4; B5 b5; 
#include "AsyncUpdaterTemplate.h"
#undef ASYNCUPDATER_PARAM_COUNT
#undef ASYNCUPDATER_TEMPLATE_PARAMS
#undef ASYNCUPDATER_TEMPLATE_ARGS
#undef ASYNCUPDATER_PARAMS
#undef ASYNCUPDATER_ARGS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS
#undef ASYNCUPDATER_MESSAGE_PARAMS
#undef ASYNCUPDATER_MESSAGE_ARGS
#undef ASYNCUPDATER_MESSAGE_CALL_ARGS
#undef ASYNCUPDATER_MESSAGE_SET_DATA
#undef ASYNCUPDATER_MESSAGE_DATA

// 6 params
#define ASYNCUPDATER_PARAM_COUNT 6
#define ASYNCUPDATER_TEMPLATE_PARAMS typename A1, typename A2, typename A3, typename A4, typename A5, typename A6
#define ASYNCUPDATER_TEMPLATE_ARGS A1, A2, A3, A4, A5, A6
#define ASYNCUPDATER_PARAMS A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6
#define ASYNCUPDATER_ARGS a1, a2, a3, a4, a5, a6
#define ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS typename B1, typename B2, typename B3, typename B4, typename B5, typename B6
#define ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS B1, B2, B3, B4, B5, B6
#define ASYNCUPDATER_MESSAGE_PARAMS B1 b1, B2 b2, B3 b3, B4 b4, B5 b5, B6 b6
#define ASYNCUPDATER_MESSAGE_ARGS b1, b2, b3, b4, b5, b6
#define ASYNCUPDATER_MESSAGE_CALL_ARGS activeMessage->b1, activeMessage->b2, activeMessage->b3, activeMessage->b4, activeMessage->b5, activeMessage->b6
#define ASYNCUPDATER_MESSAGE_SET_DATA b1 = b1; b2 = b2; b3 = b3; b4 = b4; b5 = b5; b6 = b6; 
#define ASYNCUPDATER_MESSAGE_DATA B1 b1; B2 b2; B3 b3; B4 b4; B5 b5; B6 b6; 
#include "AsyncUpdaterTemplate.h"
#undef ASYNCUPDATER_PARAM_COUNT
#undef ASYNCUPDATER_TEMPLATE_PARAMS
#undef ASYNCUPDATER_TEMPLATE_ARGS
#undef ASYNCUPDATER_PARAMS
#undef ASYNCUPDATER_ARGS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS
#undef ASYNCUPDATER_MESSAGE_PARAMS
#undef ASYNCUPDATER_MESSAGE_ARGS
#undef ASYNCUPDATER_MESSAGE_CALL_ARGS
#undef ASYNCUPDATER_MESSAGE_SET_DATA
#undef ASYNCUPDATER_MESSAGE_DATA

// 7 params
#define ASYNCUPDATER_PARAM_COUNT 7
#define ASYNCUPDATER_TEMPLATE_PARAMS typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7
#define ASYNCUPDATER_TEMPLATE_ARGS A1, A2, A3, A4, A5, A6, A7
#define ASYNCUPDATER_PARAMS A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7
#define ASYNCUPDATER_ARGS a1, a2, a3, a4, a5, a6, a7
#define ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS typename B1, typename B2, typename B3, typename B4, typename B5, typename B6, typename B7
#define ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS B1, B2, B3, B4, B5, B6, B7
#define ASYNCUPDATER_MESSAGE_PARAMS B1 b1, B2 b2, B3 b3, B4 b4, B5 b5, B6 b6, B7 b7
#define ASYNCUPDATER_MESSAGE_ARGS b1, b2, b3, b4, b5, b6, b7
#define ASYNCUPDATER_MESSAGE_CALL_ARGS activeMessage->b1, activeMessage->b2, activeMessage->b3, activeMessage->b4, activeMessage->b5, activeMessage->b6, activeMessage->b7
#define ASYNCUPDATER_MESSAGE_SET_DATA b1 = b1; b2 = b2; b3 = b3; b4 = b4; b5 = b5; b6 = b6; b7 = b7; 
#define ASYNCUPDATER_MESSAGE_DATA B1 b1; B2 b2; B3 b3; B4 b4; B5 b5; B6 b6; B7 b7; 
#include "AsyncUpdaterTemplate.h"
#undef ASYNCUPDATER_PARAM_COUNT
#undef ASYNCUPDATER_TEMPLATE_PARAMS
#undef ASYNCUPDATER_TEMPLATE_ARGS
#undef ASYNCUPDATER_PARAMS
#undef ASYNCUPDATER_ARGS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS
#undef ASYNCUPDATER_MESSAGE_PARAMS
#undef ASYNCUPDATER_MESSAGE_ARGS
#undef ASYNCUPDATER_MESSAGE_CALL_ARGS
#undef ASYNCUPDATER_MESSAGE_SET_DATA
#undef ASYNCUPDATER_MESSAGE_DATA

// 8 params
#define ASYNCUPDATER_PARAM_COUNT 8
#define ASYNCUPDATER_TEMPLATE_PARAMS typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8
#define ASYNCUPDATER_TEMPLATE_ARGS A1, A2, A3, A4, A5, A6, A7, A8
#define ASYNCUPDATER_PARAMS A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8
#define ASYNCUPDATER_ARGS a1, a2, a3, a4, a5, a6, a7, a8
#define ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS typename B1, typename B2, typename B3, typename B4, typename B5, typename B6, typename B7, typename B8
#define ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS B1, B2, B3, B4, B5, B6, B7, B8
#define ASYNCUPDATER_MESSAGE_PARAMS B1 b1, B2 b2, B3 b3, B4 b4, B5 b5, B6 b6, B7 b7, B8 b8
#define ASYNCUPDATER_MESSAGE_ARGS b1, b2, b3, b4, b5, b6, b7, b8
#define ASYNCUPDATER_MESSAGE_CALL_ARGS activeMessage->b1, activeMessage->b2, activeMessage->b3, activeMessage->b4, activeMessage->b5, activeMessage->b6, activeMessage->b7, activeMessage->b8
#define ASYNCUPDATER_MESSAGE_SET_DATA b1 = b1; b2 = b2; b3 = b3; b4 = b4; b5 = b5; b6 = b6; b7 = b7; b8 = b8; 
#define ASYNCUPDATER_MESSAGE_DATA B1 b1; B2 b2; B3 b3; B4 b4; B5 b5; B6 b6; B7 b7; B8 b8; 
#include "AsyncUpdaterTemplate.h"
#undef ASYNCUPDATER_PARAM_COUNT
#undef ASYNCUPDATER_TEMPLATE_PARAMS
#undef ASYNCUPDATER_TEMPLATE_ARGS
#undef ASYNCUPDATER_PARAMS
#undef ASYNCUPDATER_ARGS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS
#undef ASYNCUPDATER_MESSAGE_PARAMS
#undef ASYNCUPDATER_MESSAGE_ARGS
#undef ASYNCUPDATER_MESSAGE_CALL_ARGS
#undef ASYNCUPDATER_MESSAGE_SET_DATA
#undef ASYNCUPDATER_MESSAGE_DATA

// 9 params
#define ASYNCUPDATER_PARAM_COUNT 9
#define ASYNCUPDATER_TEMPLATE_PARAMS typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9
#define ASYNCUPDATER_TEMPLATE_ARGS A1, A2, A3, A4, A5, A6, A7, A8, A9
#define ASYNCUPDATER_PARAMS A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9
#define ASYNCUPDATER_ARGS a1, a2, a3, a4, a5, a6, a7, a8, a9
#define ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS typename B1, typename B2, typename B3, typename B4, typename B5, typename B6, typename B7, typename B8, typename B9
#define ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS B1, B2, B3, B4, B5, B6, B7, B8, B9
#define ASYNCUPDATER_MESSAGE_PARAMS B1 b1, B2 b2, B3 b3, B4 b4, B5 b5, B6 b6, B7 b7, B8 b8, B9 b9
#define ASYNCUPDATER_MESSAGE_ARGS b1, b2, b3, b4, b5, b6, b7, b8, b9
#define ASYNCUPDATER_MESSAGE_CALL_ARGS activeMessage->b1, activeMessage->b2, activeMessage->b3, activeMessage->b4, activeMessage->b5, activeMessage->b6, activeMessage->b7, activeMessage->b8, activeMessage->b9
#define ASYNCUPDATER_MESSAGE_SET_DATA b1 = b1; b2 = b2; b3 = b3; b4 = b4; b5 = b5; b6 = b6; b7 = b7; b8 = b8; b9 = b9; 
#define ASYNCUPDATER_MESSAGE_DATA B1 b1; B2 b2; B3 b3; B4 b4; B5 b5; B6 b6; B7 b7; B8 b8; B9 b9; 
#include "AsyncUpdaterTemplate.h"
#undef ASYNCUPDATER_PARAM_COUNT
#undef ASYNCUPDATER_TEMPLATE_PARAMS
#undef ASYNCUPDATER_TEMPLATE_ARGS
#undef ASYNCUPDATER_PARAMS
#undef ASYNCUPDATER_ARGS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS
#undef ASYNCUPDATER_MESSAGE_PARAMS
#undef ASYNCUPDATER_MESSAGE_ARGS
#undef ASYNCUPDATER_MESSAGE_CALL_ARGS
#undef ASYNCUPDATER_MESSAGE_SET_DATA
#undef ASYNCUPDATER_MESSAGE_DATA

// 10 params
#define ASYNCUPDATER_PARAM_COUNT 10
#define ASYNCUPDATER_TEMPLATE_PARAMS typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10
#define ASYNCUPDATER_TEMPLATE_ARGS A1, A2, A3, A4, A5, A6, A7, A8, A9, A10
#define ASYNCUPDATER_PARAMS A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10
#define ASYNCUPDATER_ARGS a1, a2, a3, a4, a5, a6, a7, a8, a9, a10
#define ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS typename B1, typename B2, typename B3, typename B4, typename B5, typename B6, typename B7, typename B8, typename B9, typename B10
#define ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS B1, B2, B3, B4, B5, B6, B7, B8, B9, B10
#define ASYNCUPDATER_MESSAGE_PARAMS B1 b1, B2 b2, B3 b3, B4 b4, B5 b5, B6 b6, B7 b7, B8 b8, B9 b9, B10 b10
#define ASYNCUPDATER_MESSAGE_ARGS b1, b2, b3, b4, b5, b6, b7, b8, b9, b10
#define ASYNCUPDATER_MESSAGE_CALL_ARGS activeMessage->b1, activeMessage->b2, activeMessage->b3, activeMessage->b4, activeMessage->b5, activeMessage->b6, activeMessage->b7, activeMessage->b8, activeMessage->b9, activeMessage->b10
#define ASYNCUPDATER_MESSAGE_SET_DATA b1 = b1; b2 = b2; b3 = b3; b4 = b4; b5 = b5; b6 = b6; b7 = b7; b8 = b8; b9 = b9; b10 = b10; 
#define ASYNCUPDATER_MESSAGE_DATA B1 b1; B2 b2; B3 b3; B4 b4; B5 b5; B6 b6; B7 b7; B8 b8; B9 b9; B10 b10; 
#include "AsyncUpdaterTemplate.h"
#undef ASYNCUPDATER_PARAM_COUNT
#undef ASYNCUPDATER_TEMPLATE_PARAMS
#undef ASYNCUPDATER_TEMPLATE_ARGS
#undef ASYNCUPDATER_PARAMS
#undef ASYNCUPDATER_ARGS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS
#undef ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS
#undef ASYNCUPDATER_MESSAGE_PARAMS
#undef ASYNCUPDATER_MESSAGE_ARGS
#undef ASYNCUPDATER_MESSAGE_CALL_ARGS
#undef ASYNCUPDATER_MESSAGE_SET_DATA
#undef ASYNCUPDATER_MESSAGE_DATA

rebuild_asyncupdater_list.pl

#/usr/bin/perl
use strict;

#configuration
my $max_param_count = 10;

#implementation
open(OUTPUT, ">AsyncUpdaterList.h") || die $!;
print(OUTPUT "// Automaticly generaged by $0\n\n");

my @param_list;
for (my $param_count = 0; $param_count <= $max_param_count;
        push(@param_list, ++$param_count))
{
    print(OUTPUT "// $param_count params\n");

    print(OUTPUT "#define ASYNCUPDATER_PARAM_COUNT $param_count\n");

    print(OUTPUT "#define ASYNCUPDATER_TEMPLATE_PARAMS ",
        join(", ", map({"typename A$_"} @param_list)), "\n");

    print(OUTPUT "#define ASYNCUPDATER_TEMPLATE_ARGS ",
        join(", ", map({"A$_"} @param_list)), "\n");

    print(OUTPUT "#define ASYNCUPDATER_PARAMS ",
        join(", ", map({"A$_ a$_"} @param_list)), "\n");

    print(OUTPUT "#define ASYNCUPDATER_ARGS ",
        join(", ", map({"a$_"} @param_list)), "\n");

    print(OUTPUT "#define ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS ",
        join(", ", map({"typename B$_"} @param_list)), "\n");

    print(OUTPUT "#define ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS ",
        join(", ", map({"B$_"} @param_list)), "\n");

    print(OUTPUT "#define ASYNCUPDATER_MESSAGE_PARAMS ",
        join(", ", map({"B$_ b$_"} @param_list)), "\n");

    print(OUTPUT "#define ASYNCUPDATER_MESSAGE_ARGS ",
        join(", ", map({"b$_"} @param_list)), "\n");

    print(OUTPUT "#define ASYNCUPDATER_MESSAGE_CALL_ARGS ",
        join(", ", map({"activeMessage->b$_"} @param_list)), "\n");

    print(OUTPUT "#define ASYNCUPDATER_MESSAGE_SET_DATA ",
        map({"b$_ = b$_; "} @param_list), "\n");

    print(OUTPUT "#define ASYNCUPDATER_MESSAGE_DATA ",
        map({"B$_ b$_; "} @param_list), "\n");

    print(OUTPUT '#include "AsyncUpdaterTemplate.h"', "\n",
        "#undef ASYNCUPDATER_PARAM_COUNT\n",
        "#undef ASYNCUPDATER_TEMPLATE_PARAMS\n",
        "#undef ASYNCUPDATER_TEMPLATE_ARGS\n",
        "#undef ASYNCUPDATER_PARAMS\n",
        "#undef ASYNCUPDATER_ARGS\n",
        "#undef ASYNCUPDATER_MESSAGE_TEMPLATE_PARAMS\n",
        "#undef ASYNCUPDATER_MESSAGE_TEMPLATE_ARGS\n",
        "#undef ASYNCUPDATER_MESSAGE_PARAMS\n",
        "#undef ASYNCUPDATER_MESSAGE_ARGS\n",
        "#undef ASYNCUPDATER_MESSAGE_CALL_ARGS\n",
        "#undef ASYNCUPDATER_MESSAGE_SET_DATA\n",
        "#undef ASYNCUPDATER_MESSAGE_DATA\n",
        "\n");
}
close(OUTPUT) || die $!;
0;

Probably on newer compilers it is possible to avoid appending the number of arguments after classes’ name.


#2

this class is quite old and clunky…

see http://www.juce.com/forum/topic/async-addition-listenerlist