
Jason Hise wrote:
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) ( [...] ) [, ...] ); };
It would be nicer to have the more natural, intuitive syntax for invoking methods which you could do by making use of boost::function like the interface library does. Active lambdas could be done by having: future< int > f = active< function< int ( int ) > >( _1 = _1 * 2 )( 2 ); or something similar. This will probably not work as is, but that would be how I see active lambdas (at the moment). - Reece