Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
mutex: <tt><mutex></tt> backports and Thread Safety Analysis compatible wrappers.

The mutex subpackage provides backports of the content of <mutex> from newer C++ versions, as well as providing thin wrappers around std::mutex, std::timed_mutex, and std::lock_guard suitable for use with Thread Safety Analysis.

The public header is

Public export header for the mutex subpackage.

The Bazel target is

//:mutex

Thread Safety Analysis Capability Wrappers

In order for TSA to function correctly, synchronization primitives need to be annotated as capabilities. libcxx provides appropriately annotated capabilities directly in <mutex>, but for other stdlib implementations they must be provided manually. To support this, the following annotated types are provided:

Their usage is identical to their stdlib equivalents.

Note
It is recommended to always use the TSA-compatible types from this subpackage instead of their raw stdlib equivalents in order to maximize the possibility of protection from TSA: the wrappers are zero-overhead abstractions, so there is no runtime performance penalty. In addition, when compiling with a compiler that does not support TSA or when using a stdlib which already supports TSA such as libcxx, these types become simple aliases to their stdlib counterparts to improve compile times.