Thread-safety and lazy-initialization of libraries

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 30 14:05:30 PDT 2014


Sergey Protko:

> 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.

I think module "static this" is thread-local, so in theory you 
can use that. But I don't know if it's a good idea to perform 
heavy computations inside those module static this.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list