Request: MultiAsyncUpdater

Hi, it’s some time that I have this thought in the back of my mind: what do you think about implementing a MultiAsyncUpdate where you could pass an int to the triggerAsyncUpdate() call, and then have the same int posted to the handleAsyncUpdate() callback?

It’d be in the same relation to the current AsyncUpdater as the MultiTimer is to the Timer and, given that the current AsyncUpdater already works like a charm, it shouldn’t be too difficult to implement it. I could even have a look at it myself if jules thinks it could find its way into the JUCE tip

Actually, that’s pretty much exactly the kind of design that I don’t want to move towards these days! The old MultiTimer class is a nasty hack, not something I’m proud of. I’ve only kept it around because people are using it.

The “correct” way to do that kind of thing will be with C++11 lambdas, so that you can kick off a timer or asyncupdater and just give it whatever code you want it to call. I’m looking forward to adding that when there’s more widespread support for lambdas (not long now, I think), so I don’t want to muddy the waters before that.

The vf::CallQueue generalizes this behavior, while vf::MessageThread specializes it for the GUI thread using an AsyncUpdater.

For example:

struct C
  void foo (String s);

C* c = new c;
vf::MessageThread::call (&C::foo, c, "Hello");

This is like calling a c++11 lambda only without the language extensions.

Two points to conclude:

  1. It can be built it on top of the existing AsyncUpdater, without changing it
  2. This behavior is implemented in VFLib

Lambdas (v1.1) are fully supported in VS2012, XCode 4.5 and GCC.

Ok, maybe instead of “widespread support”, I should really have said “widespread adoption”. I doubt if many people on Windows are using VC2012 yet, and that’ll take a long time to change.

I’m still with VS 2008 :oops:

This need to be fixed!

Edit: OOps wrong topic! There are many people (like me) who use VS 2008