$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: [boost] [async] joiner RAII (was Re: [thread] Do we need thread_group now?)
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2012-04-15 05:12:19
Le 15/04/12 09:46, Ben Pope a écrit :
> On Sunday, April 15, 2012 08:22 AM, Vicente J. Botet Escriba wrote:
>> E.g. I have started to implement some breaking changes on 
>> Boost.Thread as e.g. an incompatibility with the C++11 semantics of 
>> the thread destructor. Boost.Thread detach the thread at destruction 
>> time, C++11 calls std::terminate if the thread is joinable at 
>> destruction time. I have already started the stage 0th and I would 
>> like to pass to the stage 1st for the next release.
>
> In this case, it would be useful to have RAII classes for joining and 
> detaching to prevent std::terminate from being called.  In fact, I 
> think Anthony writes in his book that scope based thread_joiner should 
> be implemented by the user since it didn't make the standard.
>
Hi,
The breaking change is due to an incompatibility with the C++ standard. 
I think it is better to behave like the standard and add something on 
top of it.
Kevlin Henney proposed a different design for C++ threads 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1883.pdf 
"Preliminary Threading Library Proposal for TR2" that was based on the 
idea that the creation of a thread return always a RAII movable joiner.
{
   joiner j = thread(...);
}
The standard use of futures and async is quite close
{
   future<T> ft = async(...);
}
but here the thread is no more managed by the user.
Long time ago, I implemented something like that on top of Boost.Thread 
on TBoost.Async  that is a mix of a RAII joiner and a future. The class  
had a parameter to control the destruction behavior
     enum type {
         do_terminate,
         do_join,
         do_detach
     };
( See 
<https://svn.boost.org/svn/boost/sandbox/async/libs/async/doc/html/toward_boost_async/reference/ae_act_models_reference.html#toward_boost_async.reference.ae_act_models_reference.threader_hpp.template_class__shared_joiner___>). 
Unfortunately this has not been updated even tested since a long time 
also and the documentation need some work also :(
IMO, TBoost.Async provides an interesting framework for asynchronous calls.
Let me know if there is an interest to resurecting this project. I will 
comeback to as soon as possible to  check it works yet and adapt it to 
the new standard interface.
Best,
Vicente