This library is not designed to be thread-safe. However, it should be safe to use one lcb_INSTANCE object per thread, with some caveats and careful consideration.
- You must be certain that the lcb_INSTANCE is not shared with other threads. For performance, there are no internal locks or other thread safety mechanisms to protect internal data structures.
- Also for performance reasons, the default logger is not thread-safe, and is not bound to a single lcb_INSTANCE. Therefore, a multi-threaded application must also override the logger with a thread-safe version or use a separate logger for each instance (see example example/threads-private/threads-private.c).
- Likewise, any other shared instances that are registered with the library (e.g., lcb_io_opt_t) must also be protected in a similar manner. Such instances must either be protected and made thread-safe internally or a new instance per lcb_INSTANCE can be provided.
As with any multi-threaded application extra testing and analysis should be done using a tool like Valgrind/DRD, ThreadSanitizer or similar.