Boost logo

Boost :

From: Jason Hise (chaos_at_[hidden])
Date: 2005-11-01 12:48:05


Reece Dunn wrote:

>Active objects would be very hard to do *automatically* since the object is
>a thread (very neat concept), with the constructor, methods and destructor
>being processed as messages to the object's thread.
>
The main obstacle in making them work automatically is the desire to
give them familiar syntax. If the desire to call methods directly can
be overlooked, it seems perfectly possible to offer a generic solution.
A simplified declaration for active <> might look something like this:

template < typename Type >
struct active : private Type
{
    active( [...] );

    template < typename ReturnType [, ...] >
    future < ReturnType > enqueue( ReturnType (Type::*func) ( [...] ) [,
...] );
};

The [...]s represent where BOOST_PP adds parameters as it generates
versions of the functions taking any number of arguments (I have used
this technique before when working on singleton, so I know it is
viable). To use this, you would just create an active < MyType > object
and enqueue requests by passing member functions to the enqueue method.
Wouldn't this design work reasonably cleanly?

-Jason


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk