Boost logo

Boost :

From: Pete Becker (petebecker_at_[hidden])
Date: 2002-08-06 08:22:44


At 08:48 AM 8/6/2002 -0400, Moore, Dave wrote:
>I think the idea of parameterizing the return value has merit on the
>"syntactic sugar" side of things, as the user doesn't have to create their
>own boost::function just so they can extract a return value - they can still
>pass simple function pointers.

Function pointers are a C solution, not a C++ solution. Rather than beefing
up the C solution, I suggest a more object-oriented solution: a class with
a member function that runs in a separate thread. These have been around
for years, dating from long before the days of Java:

class thread
{
public:
         thread();
         ~thread();
         void start();
private:
         virtual void run() = 0;
};

Derived classes can hold whatever data they need. When the thread finishes,
the object's data can be examined to get the result. (Of course, thread
would have more member functions than I'velisted, in order to be able to
query the status of the thread)

        -- Pete

Dinkumware, Ltd.
"Genuine Software"


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