microsoft / arcana.cpp

Arcana.cpp is a collection of helpers and utility code for low overhead, cross platform C++ implementation of task-based asynchrony.
MIT License
78 stars 24 forks source link

Delay static variable initialization until it's actually used #44

Closed bghgary closed 3 months ago

bghgary commented 3 months ago

This avoids an issue if this code ends up in a DLL that is loaded in managed code on Windows platforms.

Static variables are initialized when the DLL loads. DLLs can load during DllMain. This particular static variable will do some locking which throws OS warnings to the debug output. See Another reason not to do anything scary in your DllMain: Inadvertent deadlock - The Old New Thing (microsoft.com) for more information.