Boost logo

Boost :

From: Moore, Dave (dmoore_at_[hidden])
Date: 2002-08-06 09:20:24

> 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:

I didn't mean to be pushing a C solution... I think the use of
boost::function provides a different means of holding data and the function
pointer compared to the polymorphic solution below. I'm not good at picking
amongst the alternatives in a case like this. Your solution with virtual
void run() seems more familiar to my personal use of C++, but
boost::function is a powerful tool I'm learning to use as well.

I happen to like the fact that boost::function lets me be lazy and specify C
functions directly to my boost::threads, but that's a personal preference
made with the recognition of what boost::function can do for me here.

Both solutions let the user not worry about the rest of the thread class,
which is what's really important here.


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