# core.runtime

The runtime module exposes information specific to the D runtime code.
License:
Boost License 1.0.
Authors:
Sean Kelly
Copyright Sean Kelly 2005 - 2009. Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at
http:
//www.boost.org/LICENSE_1_0.txt

struct Runtime;
  This struct encapsulates all functionality related to the underlying runtime module for the calling context.
  static bool initialize(ExceptionHandler dg = null);
    Initializes the runtime. This call is to be used in instances where the standard program initialization process is not executed. This is most often in shared libraries or in libraries linked to a C program.
    Params:

    ExceptionHandler dg | A delegate which will receive any exception thrown during the initialization process or null if such exceptions should be discarded.

    Returns:
    true if initialization succeeds and false if initialization fails.
  static bool terminate(ExceptionHandler dg = null);
    Terminates the runtime. This call is to be used in instances where the standard program termination process will not be not executed. This is most often in shared libraries or in libraries linked to a C program.
    Params:

    ExceptionHandler dg | A delegate which will receive any exception thrown during the termination process or null if such exceptions should be discarded.

    Returns:
    true if termination succeeds and false if termination fails.
  deprecated static bool isHalting();
    Returns true if the runtime is halting. Under normal circumstances, this will be set between the time that normal application code has exited and before module dtors are called.
    Returns:
    true if the runtime is halting.
  static string[] args();
    Returns the arguments supplied when the process was started.
    Returns:
    The arguments supplied when this process was started.
  static void* loadLibrary(in char[] name);
    Locates a dynamic library with the supplied library name and dynamically loads it into the caller's address space. If the library contains a D runtime it will be integrated with the current runtime.
    Params:

    char[] name | The name of the dynamic library to load.

    Returns:
    A reference to the library or null on error.
  static bool unloadLibrary(void* p);
    Unloads the dynamic library referenced by p. If this library contains a D runtime then any necessary finalization or cleanup of that runtime will be performed.
    Params:

    void* p | A reference to the library to unload.

  static void traceHandler(TraceHandler h);
    Overrides the default trace mechanism with s user-supplied version. A trace represents the context from which an exception was thrown, and the trace handler will be called when this occurs. The pointer supplied to this routine indicates the base address from which tracing should occur. If the supplied pointer is null then the trace routine should determine an appropriate calling context from which to begin the trace.
    Params:

    TraceHandler h | The new trace handler. Set to null to use the default handler.

  static TraceHandler traceHandler();
    Gets the current trace handler.
    Returns:
    The current trace handler or null if no trace handler is set.
  static void collectHandler(CollectHandler h);
    Overrides the default collect hander with a user-supplied version. This routine will be called for each resource object that is finalized in a non-deterministic manner--typically during a garbage collection cycle. If the supplied routine returns true then the object's dtor will called as normal, but if the routine returns false than the dtor will not be called. The default behavior is for all object dtors to be called.
    Params:

    CollectHandler h | The new collect handler. Set to null to use the default handler.

  static CollectHandler collectHandler();
    Gets the current collect handler.
    Returns:
    The current collect handler or null if no trace handler is set.
  static void moduleUnitTester(ModuleUnitTester h);
    Overrides the default module unit tester with a user-supplied version. This routine will be called once on program initialization. The return value of this routine indicates to the runtime whether the tests ran without error.
    Params:

    ModuleUnitTester h | The new unit tester. Set to null to use the default unit tester.

  static ModuleUnitTester moduleUnitTester();
    Gets the current module unit tester.
    Returns:
    The current module unit tester handler or null if no trace handler is set.
bool runModuleUnitTests();
  This routine is called by the runtime to run module unit tests on startup. The user-supplied unit tester will be called if one has been supplied, otherwise all unit tests will be run in sequence.
  Returns:
  true if execution should continue after testing is complete and false if not. Default behavior is to return true.
Throwable.TraceInfo defaultTraceHandler(void* ptr = null);

Page generated by Ddoc. Copyright Sean Kelly 2005 - 2009.