www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Runtime termination hook?

reply Jacob Carlborg <doob me.com> writes:
Is there an event that I can hook into which is called when the runtime 
is terminated?

-- 
/Jacob Carlborg
Sep 25 2012
parent reply Sean Kelly <sean invisibleduck.org> writes:
On Sep 25, 2012, at 12:44 PM, Jacob Carlborg <doob me.com> wrote:

 Is there an event that I can hook into which is called when the runtime is=
terminated? A shared static dtor?=
Sep 25 2012
parent reply Jacob Carlborg <doob me.com> writes:
On 2012-09-26 07:37, Sean Kelly wrote:

 A shared static dtor?
Didn't think of that. When exactly are those run? I'm looking for something corresponding to this Java method: http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Runtime.html#addShutdownHook%28java.lang.Thread%29 -- /Jacob Carlborg
Sep 25 2012
parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Wed, 26 Sep 2012 02:16:31 -0400, Jacob Carlborg <doob me.com> wrote:

 On 2012-09-26 07:37, Sean Kelly wrote:

 A shared static dtor?
Didn't think of that. When exactly are those run?
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L319 -Steve
Sep 27 2012
parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Thu, 27 Sep 2012 08:03:39 -0400, Steven Schveighoffer  
<schveiguy yahoo.com> wrote:

 On Wed, 26 Sep 2012 02:16:31 -0400, Jacob Carlborg <doob me.com> wrote:

 On 2012-09-26 07:37, Sean Kelly wrote:

 A shared static dtor?
Didn't think of that. When exactly are those run?
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L319
I guess here too: https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L549 -Steve
Sep 27 2012
parent Jacob Carlborg <doob me.com> writes:
On 2012-09-27 14:04, Steven Schveighoffer wrote:

 I guess here too:

 https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L549
Yeah, I guess that looks close enough. BTW, "main" should really use "rt_term" and "rt_init" instead of duplicating the code. -- /Jacob Carlborg
Sep 27 2012