[cpp-threads] Asynchronous Function Proposal

Anthony Williams anthony at justsoftwaresolutions.co.uk
Mon Jun 8 22:32:07 BST 2009


Boehm, Hans wrote:
>> From:  Herb Sutter [Hans:]
>>> I would still favor sticking with Lawrence's design that avoids 
>>> (visibly) reusing threads for multiple tasks.  The issues
>> with thread
>>> locals seem to me to be far more serious for C++ than Java.  On
>>> the other hand, it would be good to set things up so that we can
>>> easily add more policies later.  (I'm assuming that thread locals
>>> with arbitrary destructors are here to stay, though I think we
>>> now have strong arguments on both sides of that issue.)
>>> 
>>> A more minimalist approach may be to support only the
>> fully_threaded
>>> policy for now, but leave room for additional policies in
>> the future.
>> 
>> I disagree. We should provide "run on another thread" (not 
>> necessarily a new thread!), "run on this thread," and 
>> "implementation decides."
>> 
> This seems to hinge on the thread-locals issue.  (Even if we say
> "new" thread in the standard, the underlying threads implementation
> can of course still cache.  The real difference seems to be whether
> you get new thread_local variables or not.)

You can detect thread reuse with std::this_thread::get_id() as well as 
with thread-locals. But the thread-locals is the major issue.

Anthony
-- 
Author of C++ Concurrency in Action | http://www.manning.com/williams
just::thread C++0x thread library   | http://www.stdthread.co.uk
Just Software Solutions Ltd         | http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976



More information about the cpp-threads mailing list