Ideas for runtime loading of shared libraries.

Jonathan M Davis jmdavisProg at gmx.com
Fri Mar 8 01:34:17 PST 2013


On Friday, March 08, 2013 10:09:33 Jacob Carlborg wrote:
> On 2013-03-08 01:17, Walter Bright wrote:
> > D doesn't guarantee that finalizers will run on GC allocated objects.
> > Therefore, when unloading a dll:
> > 
> > 1. run a gc collection
> > 2. for all objects remaining on the heap
> > 
> >         if they have a finalizer and that finalizer points into the dll
> > 
> > code
> > 
> >              mark them as not having a finalizer
> 
> Could we do something like I suggested in another post:
> 
> We could create a standard plugin interface in Phobos or druntime,
> something like:
> 
> interface Plugin
> {
>      void initialize ();
>      void terminate ();
> }
> 
> Every plugin should implement this directly or indirectly. "initialize"
> would be called just after the plugin is loaded and "terminate" would be
> called just before unloading.
> 
> The plugin would then have a possibility to cleanup after itself.

That's basically what static constructors and destructors do, and it'll be a 
problem if they aren't run when the library is loaded and unloaded.

- Jonathan M Davis


More information about the Digitalmars-d mailing list