For some research i decided to write small high-level binding for
libmpg123.
The question is how to write thread-safe lazy-initialization of
library.
libmpg123 has mpg123_init and mpg123_exit functions, which are
not thread-safe, so we should to call them only once per process.
Most of useful libraries also has such stuff. But manual
initialization is killing all beauty of high-level bindings.
Is there any proper way to do on-demand lazy-initialization of
used library, which will be also thread-safe? How do i need to
handle cases where some methods, which requires library to be
initialized, called from different threads at the same time?
Thanks for your answers.
- Thread-safety and lazy-initializat... Sergey Protko via Digitalmars-d-learn
-