[cpp-threads] Asynchronous Execution Issues (caching_async)

Herb Sutter hsutter at microsoft.com
Mon May 4 18:24:44 BST 2009


Anthony:
> > I support that in principle, but unless we make things
> > obvious and easy, people will complain about how C++0x lacks
> > obvious things like detached threads and simulate it with things like
> >
> >     new thread(some_func); // deliberate leak for a detached thread

Hans:
> C++ inherently assumes that everything has a well-defined lifetime.  I
> just don't see a way to reconcile that with a thread whose lifetime you
> can't bound.

Actually that's no longer true. You touch on a concern I raised recently on the reflector, which was that in C++0x we now support truly undestroyable objects via ~T()=delete; . For example, you can write "new T;" and it's a certain leak because there is no way you can ever delete it (modulo heroic efforts like calling operator delete explicitly). Yes, you could simulate most of this before via private dtor idioms and the like, but we've never had the ability to express an object whose lifetime can never end.

That makes me uncomfortable, but it appeared on the reflector discussion that I'm the only one. Just mentioning it again here because it touches directly on what you said here about thread objects whose lifetime you can't bound.

Herb






More information about the cpp-threads mailing list