David Abrahams wrote:
> "Peter Dimov" <[EMAIL PROTECTED]> writes:
> 
>> David Abrahams wrote:
>> 
>> [...]
>> 
>>> Well, I don't really feel like arguing about this much longer.
>> 
>> I'd love to contribute to this discussion but there's no firm ground
>> to stand on. What _are_ the concepts being discussed? I think I see
>> 
>> AsyncCall<R>
>> 
>>   AsyncCall(function<R ()> f);
>> 
>>   void operator()();
>> 
>> // effects: f();
>> 
>>   R result() const;
>> 
>> // if operator()() hasn't been invoked, throw;
>> // if operator()() is still executing, block;
>> // otherwise, return the value returned by f().
>> 
>> but I'm not sure.
> 
> That's the general idea.  Of course we can haggle over the syntactic
> details, but the main question is whether you can get a return value
> from invoking a thread function or whether you have to declare some
> "global" state and ask the thread function to modify it.

With the above AsyncCall:

async_call<int> f( bind(g, 1, 2) ); // can offer syntactic sugar here
thread t(f); // or thread(f); for extra cuteness
int r = f.result();

The alternative seems to be

async_call<int> f( bind(g, 1, 2) );
int r = f.result();

but now f is tied to boost::thread. A helper

int r = async(g, 1, 2);

seems possible with either approach.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to