[cpp-threads] Asynchronous Execution Issues
Lawrence Crowl
Lawrence at Crowl.org
Tue Apr 28 02:08:22 BST 2009
On 4/27/09, Anthony Williams <anthony at justsoftwaresolutions.co.uk> wrote:
> I agree that it's an issue, but I think "doesn't ever work"
> is an exaggeration.
Me too.
> I see several options:
>
> 1) Make it undefined behaviour for a thread_local destructor to
> access any objects of static storage duration.
>
> 2) Provide a function which a thread can call that says
> "destroy thread locals NOW", and make it undefined to access any
> thread_local after that function returns.
>
> 3) Provide a means for a thread to register a single function
> to be called after thread_local objects have been destroyed. It
> is undefined behaviour for that function to access thread_local
> objects, but it may call library functions. This function could
> then set the "done" flag.
How about a fourth option?
Add a three more "set" functions to std::promise (or an
additional parameter) that provide the additional semantics
that is_ready on the corresponding future will not be true
until the thread calling the promise has terminated.
Practically, this means that the promise::set... will need to
save the thread handle within the shared storage so that the
...future::wait... can join with the thread?
I was planning to put something in the mid-term mailing on this
issue, but I'm not doing so now. :-)
--
Lawrence Crowl
More information about the cpp-threads
mailing list