Boost logo

Boost :

From: William E. Kempf (williamkempf_at_[hidden])
Date: 2002-05-31 17:11:54

----- Original Message -----
From: "Paul Elliott" <pelliott_at_[hidden]>
To: "Boost Mailing list" <boost_at_[hidden]>
Sent: Friday, May 31, 2002 2:00 PM
Subject: [boost] thread programing by deriving?

>Thread programming by deriving. Does anyone have any classes
>that allow you to define your thread code by deriving from
>a base class?

>I am used to this style. It does not give the user the
>ability to make an error doing casting of void* in defining
>the thread run code.

Boost.Threads does not have a problem with casting void*. The thread
function is a function object that takes no parameters at all. Using
Boost.Bind or rolling your own function objects allows you to pass data with
no void* conversions. Example:

void foo(int a)

int main(int argc, char* argv[])
    boost::thread thread(boost::bind(&foo, 10));

This creates a thread using the foo function, passing it a value of 10. No
where in this code is there a void*.

If you still prefer using derivation this should be trivial to implement on
top of Boost.Threads.

Bill Kempf

Boost list run by bdawes at, gregod at, cpdaniel at, john at