Boost logo

Boost :

Subject: Re: [boost] Checking interest in DynamicLoad/DLL/DSO/Plugin library
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2014-09-02 09:00:33

2014-09-02 13:49 GMT+04:00 Niall Douglas <s_sourceforge_at_[hidden]>:

> On 2 Sep 2014 at 11:14, Antony Polukhin wrote:
> > > 1) Notification of shared library unloading and loading.
> >
> > Well, in DLL/DSO you can track loads unloads using some global variables:
> I think he meant that he wants the ability to hook into the
> load/unload of some arbitrary DLL/DSO, so like a DLL/DSO local
> atexit() as it were.

This won't be supported out of the box because there's no nice way to do it
without overhead for users that do not require such functionality.

> This is trivial to implement, simply a static object defined per
> DLL/DSO which accepts a list of bound functions to call when it gets
> destructed.
> Something kinda cool would be combining that hook with the
> pointer-to-DLL/DSO code I sent you, so you could have code like:
> // Tell me when the DLL/DSO owning this string gets unloaded so I can
> // delete my use of it
> dll_from_ptr(str)->on_unload(std::bind(this, &remove_string, str));

You are right. Added an example how to do it using the existing
functionality of the library. Example took about 30 lines of code
(including #includes, namespaces, comments, class decorations).

Best regards,
Antony Polukhin

Boost list run by bdawes at, gregod at, cpdaniel at, john at