Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2007-03-25 14:26:59


On Mar 25, 2007, at 12:03 AM, Emil Dotchevski wrote:

> On Windows, you can have two joins on the same thread. Copyable
> thread handles can support this behavior directly. How does one
> achieve the same thing with N2184::thread semantics?

You put a N2184::thread on the heap, with a condition variable, mutex
and reference count accompanying it. You then create a copyable
handle to this struct which manages the lifetime with the reference
count, and access to the thread (and other state such as whether the
thread as ended or not). It might look a lot like:

    http://braddock.com/~braddock/future/

which is currently being discussed in the boost thread titled
"[futures] untyped_promise or future<void>". As I understand it, this
copyable, mutli-join handle is currently implemented on top of (or
perhaps "usable with" is a more accurate statement than "implemented
on to of") the non-copyable boost::thread.

I do not propose that everyone who needs this functionality go out and
write their own future. Instead I propose that std::future (actually
I like the name std::shared_future) be standardized *in addition to*
the N2184::thread. The LWG has looked at futures and is currently
thinking that TR2 would be a more appropriate target for this
functionality.

-Howard


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