X-Git-Url: https://git.llucax.com/software/druntime.git/blobdiff_plain/0edf44cfdbe2262d5c50bfa7368ba2692600babc..3d4bc628056638dd5b264e8315b5e7b7fcf579e8:/src/common/core/memory.d diff --git a/src/common/core/memory.d b/src/common/core/memory.d index 65c35c8..1770dfb 100644 --- a/src/common/core/memory.d +++ b/src/common/core/memory.d @@ -47,6 +47,10 @@ private extern (C) void gc_removeRoot( void* p ); extern (C) void gc_removeRange( void* p ); + + extern (C) void* gc_getHandle(); + extern (C) void gc_setHandle( void* p ); + extern (C) void gc_endHandle(); } @@ -441,4 +445,40 @@ struct GC { gc_removeRange( p ); } + + /** + * Get handle to the collector. + * The only thing that can be done with this handle is pass it to + * setHandle(). getHandle/setHandle/endHandle work together so that + * if there are multiple instances of the gc running, only one instance + * can be set to run. + * The most common case of this is under Windows where a D application + * calls functions in a DLL that is implemented in D. + */ + + static void* getHandle() + { + return gc_getHandle(); + } + + /** + * Set handle to the collector. + * The handle p is an opaque handle, acquired by a call to + * getHandle(). + */ + + static void setHandle(void* p) + { + gc_setHandle(p); + } + + /** + * Call when done using the collector specified by the + * call to setHandle(). + */ + + static void endHandle() + { + gc_endHandle(); + } }