Boost logo

Boost :

From: Jason Turner (lefticus_at_[hidden])
Date: 2007-03-06 16:54:04

Hi everyone. I've been lurking the mailing list for a couple of months
now and this is my first post.

I've been toying with an idea now for about 9 years, since college,
which I only just realized that C++ and specifically boost gives me
the tools that I need to implement it.

I am hoping someone on this list would be willing to comment on it, as
I hope to submit it for inclusion in boost relatively soon.

The general concept is that a calling thread never waits for the
return value of a function unless it needs to. In the case where a
function is being called, this means that a new thread is created for
a function call and an asynchronous return object is returned to the
caller. For instance:

active_object::active_return<int> ar =

a boost::thread was just created which executes doStuff() and stores
the return value. The created thread is cleaned up at some later time
automatically (or during application shutdown).

The function template, active_function return immediately. The user
can then wait for doStuff to be completed when he is concerned about



int i = ar.value();

This makes creating parallel code almost trivial, which was the main
goal of the project, to make it easy to utilize newer multi-core

Similarly an active_object exists which creates a message thread for
an object and serializes all calls to the object:

The syntax for using an active_object is a little sloppy and I am not
sure I am 100% pleased with it:

  active_object::active_object<TestClass> ao(new TestClass());

  active_object::active_return<int> ar = ao << boost::function1<int,
TestClass *>(&TestClass::getInt);
  int v = ar.value();

It was only after setting out to implement the project did I realize
that this concept had been published a few years back under the name
"Active Object" ( and there
are a couple of similar implementations floating around.

Project webpage:

-Jason Turner

-- Games, Programming, Travel & other stuff

Boost list run by bdawes at, gregod at, cpdaniel at, john at