Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-02-13 07:51:27


Sean Kelly <sean_at_[hidden]> writes:

> scott wrote:
>>
>> very briefly, the boost model treats threads as a resource (fair enough
>> to :-) and submits code fragments for asynchronous execution. in the
>> alternate model, threads come about as a consequence of instantiating
>> final (a la java) objects.
>
> This is how I've always dealt with threads. I think you can create
> the same effect with Boost threads if you really want to however:
>
> struct A {
> boost::thread* t;
> A() {
> t = new boost::thread( *this );
> }
> void operator()() { ... }
> };
>
> The only irritating thing is that Boost threads need to be passed the
> executing object on construction so you need to allocate it
> dynamically.

You might be able to get around that using boost::optional.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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