Boost logo

Boost :

Subject: Re: [boost] [threads] Problem with lambda and tls
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2015-07-10 08:07:05

On 10.07.2015 14:54, Fu ji wrote:
> Hello,
> I have a problem when I use lambda in lambda and I want to obtain thread
> local storage. Here is simple example:
> auto late_connect = wakeup_signal_notify_to_connect.connect([this](){
> auto* alias_to_this = this;
> this->OnInvokeUpdate(); //here I can obtain thread local storage from boost
> auto wakeup = wakeup_signal_ptr->connect([alias_to_this]()
> {
> alias_to_this->OnInvokeUpdate(); //here I cannot obtain
> thread local storage from boost
> }
> });});
> Between first and second of invoke OnInvokeUpdate function there was no
> destructor call.
> Someone have idei why ? If I don't use alias for this in capture list there
> is the same effet.

My guess is that you have these lambdas called in different threads.

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