Thread ctors/dtors

Sean Kelly sean at invisibleduck.org
Wed Apr 29 17:35:22 PDT 2009


== Quote from dsimcha (dsimcha at yahoo.com)'s article
> == Quote from Sean Kelly (sean at invisibleduck.org)'s article
> > == Quote from dsimcha (dsimcha at yahoo.com)'s article
> > > Would it be easy to put into core.thread a mechanism that would guarantee that
> > > a set of callback functions were called from any newly created thread upon
> > > creation, or by any thread just before termination?  Of course, by thread
> > > termination, I mean if the thread terminates normally because it finishes its
> > > job, not if it gets killed externally.
> > It seems like this would be easy to do in an app without modifying the runtime.
> > Or is there some need to hook the initialization and termination of threads you
> > don't own?
> I'm talking about if you write some generic lib that needs something like this,
> and you don't want the users of the lib to have to do it manually every time they
> create a new thread.

Hm, so you want druntime to execute an arbitrary number of functions on thread
creation and termination, each of which could throw an exception?  Yuck :-)  I
guess the functions could be required to be nothrow, but it still seems like a
problem waiting to happen.  I could be convinced to make the change, but
someone would have to present a compelling case for it.



More information about the Digitalmars-d mailing list