diff --git a/BUILD.bazel b/BUILD.bazel index eb484e40..a318d190 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -76,8 +76,8 @@ expand_template( "#cmakedefine CATCH_CONFIG_WINDOWS_SEH": "", "#cmakedefine CATCH_CONFIG_USE_BUILTIN_CONSTANT_P": "", "#cmakedefine CATCH_CONFIG_NO_USE_BUILTIN_CONSTANT_P": "", - "#cmakedefine CATCH_CONFIG_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS": "", - "#cmakedefine CATCH_CONFIG_NO_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS": "", + "#cmakedefine CATCH_CONFIG_THREAD_SAFE_ASSERTIONS": "", + "#cmakedefine CATCH_CONFIG_NO_THREAD_SAFE_ASSERTIONS": "", }, template = "src/catch2/catch_user_config.hpp.in", ) diff --git a/CMake/CatchConfigOptions.cmake b/CMake/CatchConfigOptions.cmake index 3621fac0..96725066 100644 --- a/CMake/CatchConfigOptions.cmake +++ b/CMake/CatchConfigOptions.cmake @@ -45,7 +45,7 @@ set(_OverridableOptions "EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT" "USE_BUILTIN_CONSTANT_P" "DEPRECATION_ANNOTATIONS" - "EXPERIMENTAL_THREAD_SAFE_ASSERTIONS" + "THREAD_SAFE_ASSERTIONS" ) foreach(OptionName ${_OverridableOptions}) diff --git a/docs/configuration.md b/docs/configuration.md index f63a6d41..71496db0 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -17,7 +17,7 @@ [Disabling deprecation warnings](#disabling-deprecation-warnings)
[Overriding Catch's debug break (`-b`)](#overriding-catchs-debug-break--b)
[Static analysis support](#static-analysis-support)
-[Experimental thread safety](#experimental-thread-safety)
+[Thread safety in assertions (and messages)](#thread-safety-in-assertions-and-messages)
Catch2 is designed to "just work" as much as possible, and most of the configuration options below are changed automatically during compilation, @@ -316,17 +316,21 @@ no backwards compatibility guarantees._ are not meant to be runnable, only "scannable". -## Experimental thread safety + + +## Thread safety in assertions (and messages) > Introduced in Catch2 3.9.0 +> Made non-experimental in Catch2 vX.Y.Z + Catch2 can optionally support thread-safe assertions, that means, multiple user-spawned threads can use the assertion macros at the same time. Due to the performance cost this imposes even on single-threaded usage, Catch2 defaults to non-thread-safe assertions. - CATCH_CONFIG_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS // enables thread safe assertions - CATCH_CONFIG_NO_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS // force-disables thread safe assertions + CATCH_CONFIG_THREAD_SAFE_ASSERTIONS // enables thread safe assertions + CATCH_CONFIG_NO_THREAD_SAFE_ASSERTIONS // force-disables thread safe assertions See [the documentation on thread safety in Catch2](thread-safety.md#top) for details on which macros are safe and other notes. diff --git a/docs/thread-safety.md b/docs/thread-safety.md index e0092ded..aba03f55 100644 --- a/docs/thread-safety.md +++ b/docs/thread-safety.md @@ -20,7 +20,7 @@ test case macros is not thread-safe. The way sections define paths through the test is incompatible with user spawning threads arbitrarily, so this limitation is here to stay. -**Important: thread safety in Catch2 is [opt-in](configuration.md#experimental-thread-safety)** +**Important: thread safety in Catch2 is [opt-in](configuration.md#thread-safety)** ## Using assertion macros from spawned threads diff --git a/src/catch2/catch_user_config.hpp.in b/src/catch2/catch_user_config.hpp.in index 18e2ef1a..9379e1a1 100644 --- a/src/catch2/catch_user_config.hpp.in +++ b/src/catch2/catch_user_config.hpp.in @@ -196,12 +196,12 @@ #endif -#cmakedefine CATCH_CONFIG_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS -#cmakedefine CATCH_CONFIG_NO_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS +#cmakedefine CATCH_CONFIG_THREAD_SAFE_ASSERTIONS +#cmakedefine CATCH_CONFIG_NO_THREAD_SAFE_ASSERTIONS -#if defined( CATCH_CONFIG_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS ) && \ - defined( CATCH_CONFIG_NO_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS ) -# error Cannot force EXPERIMENTAL_THREAD_SAFE_ASSERTIONS to both ON and OFF +#if defined( CATCH_CONFIG_THREAD_SAFE_ASSERTIONS ) && \ + defined( CATCH_CONFIG_NO_THREAD_SAFE_ASSERTIONS ) +# error Cannot force THREAD_SAFE_ASSERTIONS to both ON and OFF #endif diff --git a/src/catch2/internal/catch_thread_local.hpp b/src/catch2/internal/catch_thread_local.hpp index b1ea2f61..83213a44 100644 --- a/src/catch2/internal/catch_thread_local.hpp +++ b/src/catch2/internal/catch_thread_local.hpp @@ -10,7 +10,7 @@ #include -#if defined( CATCH_CONFIG_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS ) +#if defined( CATCH_CONFIG_THREAD_SAFE_ASSERTIONS ) #define CATCH_INTERNAL_THREAD_LOCAL thread_local #else #define CATCH_INTERNAL_THREAD_LOCAL diff --git a/src/catch2/internal/catch_thread_support.hpp b/src/catch2/internal/catch_thread_support.hpp index 69e50c06..5d76ea32 100644 --- a/src/catch2/internal/catch_thread_support.hpp +++ b/src/catch2/internal/catch_thread_support.hpp @@ -10,7 +10,7 @@ #include -#if defined( CATCH_CONFIG_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS ) +#if defined( CATCH_CONFIG_THREAD_SAFE_ASSERTIONS ) # include # include #endif @@ -19,7 +19,7 @@ namespace Catch { namespace Detail { -#if defined( CATCH_CONFIG_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS ) +#if defined( CATCH_CONFIG_THREAD_SAFE_ASSERTIONS ) using Mutex = std::mutex; using LockGuard = std::lock_guard; struct AtomicCounts { diff --git a/tests/ExtraTests/CMakeLists.txt b/tests/ExtraTests/CMakeLists.txt index 60993b13..efa83750 100644 --- a/tests/ExtraTests/CMakeLists.txt +++ b/tests/ExtraTests/CMakeLists.txt @@ -571,7 +571,7 @@ add_executable(ThreadSafetyTests ${TESTS_DIR}/X94-ThreadSafetyTests.cpp ) target_link_libraries(ThreadSafetyTests Catch2_buildall_interface) -target_compile_definitions(ThreadSafetyTests PUBLIC CATCH_CONFIG_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS) +target_compile_definitions(ThreadSafetyTests PUBLIC CATCH_CONFIG_THREAD_SAFE_ASSERTIONS) add_test(NAME ThreadSafetyTests::ScopedMessagesAndAssertions COMMAND ThreadSafetyTests -r compact "Failed REQUIRE in the main thread is fine"