$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [threads] Launch deferred for async
From: Gavin Lambert (boost_at_[hidden])
Date: 2018-11-27 03:06:37
On 27/11/2018 02:30, Stephan Menzel wrote:
> But when i get the result:
> 
>      const bool result = ret.get();
> 
> ...the application crashes. Debugging this I came to this in
> boost/thread/future.hpp:9373
> 
>      } else if (underlying_cast<int>(policy) & int(launch::deferred)) {
>        std::terminate();
>        //BOOST_THREAD_FUTURE<R> ret;
>        //return ::boost::move(ret);
>        //          return
> boost::detail::make_future_deferred_shared_state<Rp>(
>        //              BF(
>        //                  thread_detail::decay_copy(boost::forward<F>(f))
>        //              )
>        //          );
>      } else {
> 
> To me this sounds like the application will always std::terminate() when
> launch::deferred is chosen. Why is that?
This implementation appears to be conditioned on 
BOOST_THREAD_PROVIDES_VARIADIC_THREAD -- it's implemented "properly" 
when that is defined.
In order to get that defined, you must be using at least a C++11 
conformant compiler (and compilation mode) and have explicitly defined 
the following in all translation units that use Boost.Thread (prior to 
including it):
#define BOOST_THREAD_VERSION 4
(or the equivalent project / command line option).
This also makes Boost.Thread behave a more like std::thread, which might 
have other consequences if you were relying on the previous behaviour.
I couldn't find any documentation that explains why this was left 
unimplemented for the non-variadic version; presumably there was some 
kind of compilation issue, or just an assumption that using new 
facilities requires using the latest interface version.