[cpp-threads] Asynchronous Execution Issues
    Peter Dimov 
    pdimov at mmltd.net
       
    Sat Apr 25 01:11:33 BST 2009
    
    
  
Lawrence Crowl:
> I'm worried about the thread-local variables of the new thread that
> does the work.  For instance,
>
>    thread_local complicated helper;
>
>    auto f = async( []{ return foo( &helper ); } );
>    ....
>    auto x = f.get();
>
> Running the work in another thread necessarily initializes a helper
> in that thread.
I don't think that it does. This takes the address of this thread's 'helper' 
and passes it to the thread executing the lambda. Which is typically a bad 
idea and rarely done - it's like passing the address of a private member to 
a function outside the class. 
    
    
More information about the cpp-threads
mailing list