Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2007-03-06 18:27:23


Jason Turner <lefticus <at>> writes:

> <snip>
> 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();
> <snip>

You should not store a pointer you should store
a value. If users need a pointer then they
can specify it explicitly.

  active_object::active_object<TestClass> ao;

The << operator is not appropriate. A function is better

  ao.execute(boost::function1<int,TestClass *>(&TestClass::getInt));

You could use operator() but that might still be

  ao(boost::function1<int,TestClass *>(&TestClass::getInt));

Ideally you want


But this is not possible. Another possibility is


In Christ,
Steven Watanabe

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