Boost logo

Boost :

From: Sean Kelly (sean_at_[hidden])
Date: 2004-02-13 00:21:53


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.

I'll admit I do prefer the inheritance model in most cases. Perhaps a
new class called thread_base could be added so both methods are
available? It would be a pretty simple addition.

Sean


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