Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-12-11 11:46:04


Martin Pasdzierny wrote:
> Hello boost::thread experts,
>
> does the 'thread_ref-design' as discussed previously enable the
> following scenario ?
> <code start>
>
> struct thread_class_1 {
> thread_ref tr;
> void operator()() {
> tr = get_current_thread_ref(); // view from *inside* a thread
> ...
> }
> } ;
> ...
> thread_class_1 thread_functor_1;
> boost::thread thread_1(thread_functor_1) ;

There are two problems with this code. First, under the thread_ref design,
there is no boost::thread class:

thread_ref thread1 = create_thread( thread_functor_1 );

Second, create_thread makes a copy of thread_functor_1 and runs the copy, as
is also the case with the current design.

However, thread1, as returned by create_thread, and the thread_ref returned
by current_thread inside the newly spawned thread will indeed be equivalent.
They will not only compare equal, but will be interchangeable in every way.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net