I am trying to use Boost-Deadlinetimer inside a DLL, which is loaded using boost::dll::shared_library. Following code-snippets are reduced to the essentials.
Example
Windows has a LoaderLock which is held from the call to LoadLibrary
until it returns.
This lock is used by the Windows system to ensure that the process remains stable, as cascaded DLLs are properly reference counted.
Globals which are created within a DLL, are constructed by dynamic initialization
just before DllMain runs (DLL_PROCESS_ATTACH
), and destroyed just after DllMain finishes (DLL_PROCESS_DETACH
).
When you create a DLL with a global variable, you need to follow the rules in the link, and avoid...
The easiest way to cope with this would be having a separate initialize function which is called after LoadLibrary, and a Uninitialize function called before the final FreeLibrary where global variables are separately initialized.