How to make a wrapper around a non-thread safe C library thread-safe

Dear all,

I am looking for hints how to make the NetCDF.jl prepared for the new threading in Julia 1.3. The package is a wrapper around a C library which is not thread-safe, so I think one has to make sure that only one thread at a time makes a ccall into the linked library and other threads have to wait accordingly. Is it desirable to do the locking on the library-level and if yes, are there examples where this is already implemented?

You should generally leave that to the user unless you are sure that almost all users would like to use multiple threads and you know exactly how they’ll use it.


Thanks, so I will just add a warning to the documentation of the package saying it should not be used in a threaded context (or with caution).