Skip to content

Commit

Permalink
style: Update guidance on #include <mutex>
Browse files Browse the repository at this point in the history
Can `#include <mutex>` in order to use `std::lock_guard`. However, the
other types in this header aren't guaranteed to work for a given
toolchain or OS. For types like std::mutex, pw_sync alternatives should
be preferred.

Bug: b/230744747
Change-Id: I782b02175e21a7729efd255a797ee8549541b03f
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/93221
Reviewed-by: Keir Mierle <[email protected]>
Reviewed-by: Wyatt Hepler <[email protected]>
Commit-Queue: Keir Mierle <[email protected]>
  • Loading branch information
footballhead authored and CQ Bot Account committed May 2, 2022
1 parent 0c5ac6c commit 15cd8be
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/style_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Permitted Headers
* ``<atomic>`` -- not all MCUs natively support atomic operations
* ``<bitset>`` -- conversions to or from strings are disallowed
* ``<functional>`` -- do **not** use ``std::function``
* ``<mutex>`` -- can use ``std::lock_guard``, prefer :ref:`module-pw_sync`
* ``<new>`` -- for placement new
* ``<numeric>`` -- be wary of code size with multiple template instantiations

Expand All @@ -137,7 +138,7 @@ Permitted Headers
* Dynamic containers (``<list>``, ``<map>``, ``<set>``, ``<vector>``, etc.)
* Streams (``<iostream>``, ``<ostream>``, ``<fstream>``, etc.)
* ``<exception>``
* ``<future>``, ``<mutex>``, ``<thread>``
* ``<future>``, ``<thread>``
* ``<memory>``
* ``<regex>``
* ``<scoped_allocator>``
Expand Down

0 comments on commit 15cd8be

Please sign in to comment.