Multithread support in the DLIB runtime environment
The DLIB runtime environment uses two kinds of locks—system locks and file stream locks. The file stream locks are used as guards when the state of a file stream is updated, and are only needed in the Full library configuration. The following objects are guarded with system locks:
The heap (in other words when
malloc,new,free,delete,realloc, orcallocis used).The C file system (only available in the Full library configuration), but not the file streams themselves. The file system is updated when a stream is opened or closed, in other words when
fopen,fclose,fdopen,fflush, orfreopenis used.The signal system (in other words when
signalis used).The temporary file system (in other words when
tmpnamis used).C++ dynamically initialized function-local objects with static storage duration.
C++ locale facet handling
C++ regular expression handling
C++ terminate and unexpected handling
These library objects use TLS:
Library objects using TLS | When these functions are used |
|---|---|
Error functions |
|
Note
If you are using printf/scanf (or any variants) with formatters, each individual formatter will be guarded, but the complete printf/scanf invocation will not be guarded.
If C++ is used in a runtime environment with multithread support, the compiler option ‑‑guard_calls must be used to make sure that function-static variables with dynamic initializers are not initialized simultaneously by several threads.