[{"data":1,"prerenderedAt":1326},["ShallowReactive",2],{"doc-thread-safety":3},{"id":4,"title":5,"body":6,"description":242,"extension":1318,"meta":1319,"navigation":424,"path":1320,"seo":1321,"slug":1322,"source":1323,"stem":1324,"__hash__":1325},"docs\u002Fdocs\u002Fthread-safety.md","Thread safety of the Catch3 compatibility engine",{"type":7,"value":8,"toc":1300},"minimark",[9,50,54,109,114,125,128,137,141,144,153,160,170,173,178,181,203,206,211,224,226,236,444,447,452,573,579,699,702,706,938,953,960,964,1107,1113,1126,1130,1247,1258,1265,1280,1283,1290,1293,1296],[10,11,12],"blockquote",{},[13,14,15,19,20,24,25,28,29,32,33,36,37,36,40,43,44,49],"p",{},[16,17,18],"strong",{},"Catch3 compatibility reference:"," This page describes the test-writing API Catch3 shares with Catch2: the macros, such as ",[21,22,23],"code",{},"TEST_CASE"," and ",[21,26,27],{},"REQUIRE",", and the ",[21,30,31],{},"Catch::"," namespace keep Catch2's names. Headers and build names are Catch3's own (",[21,34,35],{},"\u003CProgmasoft\u002FCatch3\u002FTestMacros.hpp>",", ",[21,38,39],{},"find_package(Catch3)",[21,41,42],{},"Catch3::Catch3WithMain","). See ",[45,46,48],"a",{"href":47},"\u002Fdocs\u002Fprogmasoft-catch3\u002F","Catch3 additions"," for Progmasoft APIs.",[51,52,5],"h1",{"id":53},"thread-safety-of-the-catch3-compatibility-engine",[13,55,56,59,62,66,68,72,74,78,80,84,86,95,97,101,103,107],{},[16,57,58],{},"Contents",[60,61],"br",{},[45,63,65],{"href":64},"#using-assertion-macros-from-spawned-threads","Using assertion macros from spawned threads",[60,67],{},[45,69,71],{"href":70},"#assertion-like-message-macros-and-spawned-threads","Assertion-like message macros and spawned threads",[60,73],{},[45,75,77],{"href":76},"#message-macros-and-spawned-threads","Message macros and spawned threads",[60,79],{},[45,81,83],{"href":82},"#examples","examples",[60,85],{},[45,87,89,24,92],{"href":88},"#static_require-and-static_check",[21,90,91],{},"STATIC_REQUIRE",[21,93,94],{},"STATIC_CHECK",[60,96],{},[45,98,100],{"href":99},"#fatal-errors-and-multiple-threads","Fatal errors and multiple threads",[60,102],{},[45,104,106],{"href":105},"#performance-overhead","Performance overhead",[60,108],{},[10,110,111],{},[13,112,113],{},"Thread safe assertions were introduced in Catch2 3.9.0",[13,115,116,117,120,121,124],{},"Thread safety in Catch2 is currently limited to all the assertion macros,\nand to message or message-adjacent macros (e.g. ",[21,118,119],{},"INFO"," or ",[21,122,123],{},"WARN",").",[13,126,127],{},"Interacting with benchmark macros, sections macros, generator macros, or\ntest case macros is not thread-safe. The way sections define paths through\nthe test is incompatible with user spawning threads arbitrarily, so this\nlimitation is here to stay.",[13,129,130],{},[16,131,132,133],{},"Important: thread safety in Catch2 is ",[45,134,136],{"href":135},"\u002Fdocs\u002Fconfiguration\u002F#thread-safety","opt-in",[138,139,65],"h2",{"id":140},"using-assertion-macros-from-spawned-threads",[13,142,143],{},"The full set of Catch2's runtime assertion macros is thread-safe. However,\nit is important to keep in mind that their semantics might not support\nbeing used from user-spawned threads.",[13,145,146,147,149,150,152],{},"Specifically, the ",[21,148,27],{}," family of assertion macros have semantics\nof stopping the test execution on failure. This is done by throwing\nan exception, but since the user-spawned thread will not have the test-level\ntry-catch block ready to catch the test failure exception, failing a\n",[21,151,27],{}," assertion inside user-spawned thread will terminate the process.",[13,154,155,156,159],{},"The ",[21,157,158],{},"CHECK"," family of assertions does not have this issue, because it\ndoes not try to stop the test execution.",[13,161,162,163,24,166,169],{},"Note that ",[21,164,165],{},"CHECKED_IF",[21,167,168],{},"CHECKED_ELSE"," are also thread safe (internally\nthey are assertion macro + an if).",[138,171,71],{"id":172},"assertion-like-message-macros-and-spawned-threads",[10,174,175],{},[13,176,177],{},"Assertion-like messages were made thread safe in Catch2 3.10.0",[13,179,180],{},"Similarly to assertion macros, not all assertion-like message macros can\nbe used from spawned thread.",[13,182,183,24,186,189,190,192,193,196,197,24,200,202],{},[21,184,185],{},"SKIP",[21,187,188],{},"FAIL"," macros stop the test execution. Just like with ",[21,191,27],{},",\nthis means that they cannot be used inside user-spawned threads. ",[21,194,195],{},"SUCCEED",",\n",[21,198,199],{},"FAIL_CHECK",[21,201,123],{}," do not attempt to stop the test execution and\nthus can be used from any thread.",[138,204,77],{"id":205},"message-macros-and-spawned-threads",[10,207,208],{},[13,209,210],{},"Message macros were made thread safe in Catch2 3.10.0",[13,212,213,214,216,217,220,221,223],{},"Macros that add extra messages to following assertion, such as ",[21,215,119],{},"\nor ",[21,218,219],{},"CAPTURE",", are all thread safe and can be used in any thread. Note\nthat these messages are per-thread, and thus ",[21,222,119],{}," inside a user-spawned\nthread will not be seen by the main thread, and vice versa.",[138,225,83],{"id":83},[227,228,230,232,233,235],"h3",{"id":229},"require-from-the-main-thread-check-from-spawned-threads",[21,231,27],{}," from the main thread, ",[21,234,158],{}," from spawned threads",[237,238,243],"pre",{"className":239,"code":240,"language":241,"meta":242,"style":242},"language-cpp shiki shiki-themes github-dark","TEST_CASE( \"Failed REQUIRE in the main thread is fine\" ) {\n    std::vector\u003Cstd::jthread> threads;\n    for ( size_t t = 0; t \u003C 16; ++t) {\n        threads.emplace_back( []() {\n            for (size_t i = 0; i \u003C 10'000; ++i) {\n                CHECK( true );\n                CHECK( false );\n            }\n        } );\n    }\n\n    REQUIRE( false );\n}\n","cpp","",[21,244,245,264,290,330,342,375,389,401,407,413,419,426,438],{"__ignoreMap":242},[246,247,250,253,257,261],"span",{"class":248,"line":249},"line",1,[246,251,23],{"class":252},"svObZ",[246,254,256],{"class":255},"s95oV","( ",[246,258,260],{"class":259},"sU2Wk","\"Failed REQUIRE in the main thread is fine\"",[246,262,263],{"class":255}," ) {\n",[246,265,267,270,273,276,279,282,284,287],{"class":248,"line":266},2,[246,268,269],{"class":252},"    std",[246,271,272],{"class":255},"::",[246,274,275],{"class":252},"vector",[246,277,278],{"class":255},"\u003C",[246,280,281],{"class":252},"std",[246,283,272],{"class":255},[246,285,286],{"class":252},"jthread",[246,288,289],{"class":255},"> threads;\n",[246,291,293,297,300,303,306,309,313,316,318,321,324,327],{"class":248,"line":292},3,[246,294,296],{"class":295},"snl16","    for",[246,298,299],{"class":255}," ( ",[246,301,302],{"class":295},"size_t",[246,304,305],{"class":255}," t ",[246,307,308],{"class":295},"=",[246,310,312],{"class":311},"sDLfK"," 0",[246,314,315],{"class":255},"; t ",[246,317,278],{"class":295},[246,319,320],{"class":311}," 16",[246,322,323],{"class":255},"; ",[246,325,326],{"class":295},"++",[246,328,329],{"class":255},"t) {\n",[246,331,333,336,339],{"class":248,"line":332},4,[246,334,335],{"class":255},"        threads.",[246,337,338],{"class":252},"emplace_back",[246,340,341],{"class":255},"( []() {\n",[246,343,345,348,351,353,356,358,360,363,365,368,370,372],{"class":248,"line":344},5,[246,346,347],{"class":295},"            for",[246,349,350],{"class":255}," (",[246,352,302],{"class":295},[246,354,355],{"class":255}," i ",[246,357,308],{"class":295},[246,359,312],{"class":311},[246,361,362],{"class":255},"; i ",[246,364,278],{"class":295},[246,366,367],{"class":311}," 10'000",[246,369,323],{"class":255},[246,371,326],{"class":295},[246,373,374],{"class":255},"i) {\n",[246,376,378,381,383,386],{"class":248,"line":377},6,[246,379,380],{"class":252},"                CHECK",[246,382,256],{"class":255},[246,384,385],{"class":311},"true",[246,387,388],{"class":255}," );\n",[246,390,392,394,396,399],{"class":248,"line":391},7,[246,393,380],{"class":252},[246,395,256],{"class":255},[246,397,398],{"class":311},"false",[246,400,388],{"class":255},[246,402,404],{"class":248,"line":403},8,[246,405,406],{"class":255},"            }\n",[246,408,410],{"class":248,"line":409},9,[246,411,412],{"class":255},"        } );\n",[246,414,416],{"class":248,"line":415},10,[246,417,418],{"class":255},"    }\n",[246,420,422],{"class":248,"line":421},11,[246,423,425],{"emptyLinePlaceholder":424},true,"\n",[246,427,429,432,434,436],{"class":248,"line":428},12,[246,430,431],{"class":252},"    REQUIRE",[246,433,256],{"class":255},[246,435,398],{"class":311},[246,437,388],{"class":255},[246,439,441],{"class":248,"line":440},13,[246,442,443],{"class":255},"}\n",[13,445,446],{},"This will work as expected, that is, the process will finish running\nnormally, the test case will fail and there will be the correct count of\npassing and failing assertions (160000 and 160001 respectively). However,\nit is important to understand that when the main thread fails its assertion,\nthe spawned threads will keep running.",[227,448,450,235],{"id":449},"require-from-spawned-threads",[21,451,27],{},[237,453,455],{"className":239,"code":454,"language":241,"meta":242,"style":242},"TEST_CASE( \"Successful REQUIRE in spawned thread is fine\" ) {\n    std::vector\u003Cstd::jthread> threads;\n    for ( size_t t = 0; t \u003C 16; ++t) {\n        threads.emplace_back( []() {\n            for (size_t i = 0; i \u003C 10'000; ++i) {\n                REQUIRE( true );\n            }\n        } );\n    }\n}\n",[21,456,457,468,486,512,520,546,557,561,565,569],{"__ignoreMap":242},[246,458,459,461,463,466],{"class":248,"line":249},[246,460,23],{"class":252},[246,462,256],{"class":255},[246,464,465],{"class":259},"\"Successful REQUIRE in spawned thread is fine\"",[246,467,263],{"class":255},[246,469,470,472,474,476,478,480,482,484],{"class":248,"line":266},[246,471,269],{"class":252},[246,473,272],{"class":255},[246,475,275],{"class":252},[246,477,278],{"class":255},[246,479,281],{"class":252},[246,481,272],{"class":255},[246,483,286],{"class":252},[246,485,289],{"class":255},[246,487,488,490,492,494,496,498,500,502,504,506,508,510],{"class":248,"line":292},[246,489,296],{"class":295},[246,491,299],{"class":255},[246,493,302],{"class":295},[246,495,305],{"class":255},[246,497,308],{"class":295},[246,499,312],{"class":311},[246,501,315],{"class":255},[246,503,278],{"class":295},[246,505,320],{"class":311},[246,507,323],{"class":255},[246,509,326],{"class":295},[246,511,329],{"class":255},[246,513,514,516,518],{"class":248,"line":332},[246,515,335],{"class":255},[246,517,338],{"class":252},[246,519,341],{"class":255},[246,521,522,524,526,528,530,532,534,536,538,540,542,544],{"class":248,"line":344},[246,523,347],{"class":295},[246,525,350],{"class":255},[246,527,302],{"class":295},[246,529,355],{"class":255},[246,531,308],{"class":295},[246,533,312],{"class":311},[246,535,362],{"class":255},[246,537,278],{"class":295},[246,539,367],{"class":311},[246,541,323],{"class":255},[246,543,326],{"class":295},[246,545,374],{"class":255},[246,547,548,551,553,555],{"class":248,"line":377},[246,549,550],{"class":252},"                REQUIRE",[246,552,256],{"class":255},[246,554,385],{"class":311},[246,556,388],{"class":255},[246,558,559],{"class":248,"line":391},[246,560,406],{"class":255},[246,562,563],{"class":248,"line":403},[246,564,412],{"class":255},[246,566,567],{"class":248,"line":409},[246,568,418],{"class":255},[246,570,571],{"class":248,"line":415},[246,572,443],{"class":255},[13,574,575,576,578],{},"This will also work as expected, because the ",[21,577,27],{}," is successful.",[237,580,582],{"className":239,"code":581,"language":241,"meta":242,"style":242},"TEST_CASE( \"Failed REQUIRE in spawned thread kills the process\" ) {\n    std::vector\u003Cstd::jthread> threads;\n    for ( size_t t = 0; t \u003C 16; ++t) {\n        threads.emplace_back( []() {\n            for (size_t i = 0; i \u003C 10'000; ++i) {\n                REQUIRE( false );\n            }\n        } );\n    }\n}\n",[21,583,584,595,613,639,647,673,683,687,691,695],{"__ignoreMap":242},[246,585,586,588,590,593],{"class":248,"line":249},[246,587,23],{"class":252},[246,589,256],{"class":255},[246,591,592],{"class":259},"\"Failed REQUIRE in spawned thread kills the process\"",[246,594,263],{"class":255},[246,596,597,599,601,603,605,607,609,611],{"class":248,"line":266},[246,598,269],{"class":252},[246,600,272],{"class":255},[246,602,275],{"class":252},[246,604,278],{"class":255},[246,606,281],{"class":252},[246,608,272],{"class":255},[246,610,286],{"class":252},[246,612,289],{"class":255},[246,614,615,617,619,621,623,625,627,629,631,633,635,637],{"class":248,"line":292},[246,616,296],{"class":295},[246,618,299],{"class":255},[246,620,302],{"class":295},[246,622,305],{"class":255},[246,624,308],{"class":295},[246,626,312],{"class":311},[246,628,315],{"class":255},[246,630,278],{"class":295},[246,632,320],{"class":311},[246,634,323],{"class":255},[246,636,326],{"class":295},[246,638,329],{"class":255},[246,640,641,643,645],{"class":248,"line":332},[246,642,335],{"class":255},[246,644,338],{"class":252},[246,646,341],{"class":255},[246,648,649,651,653,655,657,659,661,663,665,667,669,671],{"class":248,"line":344},[246,650,347],{"class":295},[246,652,350],{"class":255},[246,654,302],{"class":295},[246,656,355],{"class":255},[246,658,308],{"class":295},[246,660,312],{"class":311},[246,662,362],{"class":255},[246,664,278],{"class":295},[246,666,367],{"class":311},[246,668,323],{"class":255},[246,670,326],{"class":295},[246,672,374],{"class":255},[246,674,675,677,679,681],{"class":248,"line":377},[246,676,550],{"class":252},[246,678,256],{"class":255},[246,680,398],{"class":311},[246,682,388],{"class":255},[246,684,685],{"class":248,"line":391},[246,686,406],{"class":255},[246,688,689],{"class":248,"line":403},[246,690,412],{"class":255},[246,692,693],{"class":248,"line":409},[246,694,418],{"class":255},[246,696,697],{"class":248,"line":415},[246,698,443],{"class":255},[13,700,701],{},"This will fail catastrophically and terminate the process.",[227,703,705],{"id":704},"info-across-threads","INFO across threads",[237,707,709],{"className":239,"code":708,"language":241,"meta":242,"style":242},"TEST_CASE( \"messages don't cross threads\" ) {\n    std::jthread t1( [&]() {\n        for ( size_t i = 0; i \u003C 100; ++i ) {\n            INFO( \"spawned thread #1\" );\n            CHECK( 1 == 1 );\n        }\n    } );\n\n    std::thread t2( [&]() {\n        for (size_t i = 0; i \u003C 100; ++i) {\n            UNSCOPED_INFO( \"spawned thread #2\" );\n        }\n    } );\n\n    for (size_t i = 0; i \u003C 100; ++i) {\n        CHECK( 1 == 2 );\n    }\n}\n",[21,710,711,722,742,771,783,801,806,811,815,833,859,871,875,879,884,911,928,933],{"__ignoreMap":242},[246,712,713,715,717,720],{"class":248,"line":249},[246,714,23],{"class":252},[246,716,256],{"class":255},[246,718,719],{"class":259},"\"messages don't cross threads\"",[246,721,263],{"class":255},[246,723,724,726,728,730,733,736,739],{"class":248,"line":266},[246,725,269],{"class":252},[246,727,272],{"class":255},[246,729,286],{"class":252},[246,731,732],{"class":252}," t1",[246,734,735],{"class":255},"( [",[246,737,738],{"class":295},"&",[246,740,741],{"class":255},"]() {\n",[246,743,744,747,749,751,753,755,757,759,761,764,766,768],{"class":248,"line":292},[246,745,746],{"class":295},"        for",[246,748,299],{"class":255},[246,750,302],{"class":295},[246,752,355],{"class":255},[246,754,308],{"class":295},[246,756,312],{"class":311},[246,758,362],{"class":255},[246,760,278],{"class":295},[246,762,763],{"class":311}," 100",[246,765,323],{"class":255},[246,767,326],{"class":295},[246,769,770],{"class":255},"i ) {\n",[246,772,773,776,778,781],{"class":248,"line":332},[246,774,775],{"class":252},"            INFO",[246,777,256],{"class":255},[246,779,780],{"class":259},"\"spawned thread #1\"",[246,782,388],{"class":255},[246,784,785,788,790,793,796,799],{"class":248,"line":344},[246,786,787],{"class":252},"            CHECK",[246,789,256],{"class":255},[246,791,792],{"class":311},"1",[246,794,795],{"class":295}," ==",[246,797,798],{"class":311}," 1",[246,800,388],{"class":255},[246,802,803],{"class":248,"line":377},[246,804,805],{"class":255},"        }\n",[246,807,808],{"class":248,"line":391},[246,809,810],{"class":255},"    } );\n",[246,812,813],{"class":248,"line":403},[246,814,425],{"emptyLinePlaceholder":424},[246,816,817,819,821,824,827,829,831],{"class":248,"line":409},[246,818,269],{"class":252},[246,820,272],{"class":255},[246,822,823],{"class":252},"thread",[246,825,826],{"class":252}," t2",[246,828,735],{"class":255},[246,830,738],{"class":295},[246,832,741],{"class":255},[246,834,835,837,839,841,843,845,847,849,851,853,855,857],{"class":248,"line":415},[246,836,746],{"class":295},[246,838,350],{"class":255},[246,840,302],{"class":295},[246,842,355],{"class":255},[246,844,308],{"class":295},[246,846,312],{"class":311},[246,848,362],{"class":255},[246,850,278],{"class":295},[246,852,763],{"class":311},[246,854,323],{"class":255},[246,856,326],{"class":295},[246,858,374],{"class":255},[246,860,861,864,866,869],{"class":248,"line":421},[246,862,863],{"class":252},"            UNSCOPED_INFO",[246,865,256],{"class":255},[246,867,868],{"class":259},"\"spawned thread #2\"",[246,870,388],{"class":255},[246,872,873],{"class":248,"line":428},[246,874,805],{"class":255},[246,876,877],{"class":248,"line":440},[246,878,810],{"class":255},[246,880,882],{"class":248,"line":881},14,[246,883,425],{"emptyLinePlaceholder":424},[246,885,887,889,891,893,895,897,899,901,903,905,907,909],{"class":248,"line":886},15,[246,888,296],{"class":295},[246,890,350],{"class":255},[246,892,302],{"class":295},[246,894,355],{"class":255},[246,896,308],{"class":295},[246,898,312],{"class":311},[246,900,362],{"class":255},[246,902,278],{"class":295},[246,904,763],{"class":311},[246,906,323],{"class":255},[246,908,326],{"class":295},[246,910,374],{"class":255},[246,912,914,917,919,921,923,926],{"class":248,"line":913},16,[246,915,916],{"class":252},"        CHECK",[246,918,256],{"class":255},[246,920,792],{"class":311},[246,922,795],{"class":295},[246,924,925],{"class":311}," 2",[246,927,388],{"class":255},[246,929,931],{"class":248,"line":930},17,[246,932,418],{"class":255},[246,934,936],{"class":248,"line":935},18,[246,937,443],{"class":255},[13,939,940,941,944,945,948,949,952],{},"None of the failed checks will show the \"spawned thread #1\" message, as\nthat message is for the ",[21,942,943],{},"t1"," thread. If the reporter shows passing\nassertions (e.g. due to the tests being run with ",[21,946,947],{},"-s","), you will see the\n\"spawned thread #1\" message alongside the passing ",[21,950,951],{},"CHECK( 1 == 1 )"," assertion.",[13,954,955,956,959],{},"The message \"spawned thread #2\" will never be shown, because there are no\nassertions in ",[21,957,958],{},"t2",".",[227,961,963],{"id":962},"failskip-from-the-main-thread","FAIL\u002FSKIP from the main thread",[237,965,967],{"className":239,"code":966,"language":241,"meta":242,"style":242},"TEST_CASE( \"FAIL in the main thread is fine\" ) {\n    std::vector\u003Cstd::jthread> threads;\n    for ( size_t t = 0; t \u003C 16; ++t) {\n        threads.emplace_back( []() {\n            for (size_t i = 0; i \u003C 10; ++i) {\n                CHECK( true );\n                CHECK( false );\n            }\n        } );\n    }\n\n    FAIL();\n}\n",[21,968,969,980,998,1024,1032,1059,1069,1079,1083,1087,1091,1095,1103],{"__ignoreMap":242},[246,970,971,973,975,978],{"class":248,"line":249},[246,972,23],{"class":252},[246,974,256],{"class":255},[246,976,977],{"class":259},"\"FAIL in the main thread is fine\"",[246,979,263],{"class":255},[246,981,982,984,986,988,990,992,994,996],{"class":248,"line":266},[246,983,269],{"class":252},[246,985,272],{"class":255},[246,987,275],{"class":252},[246,989,278],{"class":255},[246,991,281],{"class":252},[246,993,272],{"class":255},[246,995,286],{"class":252},[246,997,289],{"class":255},[246,999,1000,1002,1004,1006,1008,1010,1012,1014,1016,1018,1020,1022],{"class":248,"line":292},[246,1001,296],{"class":295},[246,1003,299],{"class":255},[246,1005,302],{"class":295},[246,1007,305],{"class":255},[246,1009,308],{"class":295},[246,1011,312],{"class":311},[246,1013,315],{"class":255},[246,1015,278],{"class":295},[246,1017,320],{"class":311},[246,1019,323],{"class":255},[246,1021,326],{"class":295},[246,1023,329],{"class":255},[246,1025,1026,1028,1030],{"class":248,"line":332},[246,1027,335],{"class":255},[246,1029,338],{"class":252},[246,1031,341],{"class":255},[246,1033,1034,1036,1038,1040,1042,1044,1046,1048,1050,1053,1055,1057],{"class":248,"line":344},[246,1035,347],{"class":295},[246,1037,350],{"class":255},[246,1039,302],{"class":295},[246,1041,355],{"class":255},[246,1043,308],{"class":295},[246,1045,312],{"class":311},[246,1047,362],{"class":255},[246,1049,278],{"class":295},[246,1051,1052],{"class":311}," 10",[246,1054,323],{"class":255},[246,1056,326],{"class":295},[246,1058,374],{"class":255},[246,1060,1061,1063,1065,1067],{"class":248,"line":377},[246,1062,380],{"class":252},[246,1064,256],{"class":255},[246,1066,385],{"class":311},[246,1068,388],{"class":255},[246,1070,1071,1073,1075,1077],{"class":248,"line":391},[246,1072,380],{"class":252},[246,1074,256],{"class":255},[246,1076,398],{"class":311},[246,1078,388],{"class":255},[246,1080,1081],{"class":248,"line":403},[246,1082,406],{"class":255},[246,1084,1085],{"class":248,"line":409},[246,1086,412],{"class":255},[246,1088,1089],{"class":248,"line":415},[246,1090,418],{"class":255},[246,1092,1093],{"class":248,"line":421},[246,1094,425],{"emptyLinePlaceholder":424},[246,1096,1097,1100],{"class":248,"line":428},[246,1098,1099],{"class":252},"    FAIL",[246,1101,1102],{"class":255},"();\n",[246,1104,1105],{"class":248,"line":440},[246,1106,443],{"class":255},[13,1108,1109,1110,1112],{},"This will work as expected, that is, the process will finish running\nnormally, the test case will fail and there will be 321 total assertions,\n160 passing and 161 failing (",[21,1111,188],{}," counts as failed assertion).",[13,1114,1115,1116,1118,1119,1122,1123,1125],{},"However, when the main thread hits ",[21,1117,188],{},", it will wait for the other\nthreads to finish due to ",[21,1120,1121],{},"std::jthread","'s destructor joining the spawned\nthread. Due to this, using ",[21,1124,185],{}," is not recommended once more threads\nare spawned; while the main thread will bail from the test execution,\nthe spawned threads will keep running and may fail the test case.",[227,1127,1129],{"id":1128},"failskip-from-spawned-threads","FAIL\u002FSKIP from spawned threads",[237,1131,1133],{"className":239,"code":1132,"language":241,"meta":242,"style":242},"TEST_CASE( \"FAIL\u002FSKIP in spawned thread kills the process\" ) {\n    std::vector\u003Cstd::jthread> threads;\n    for ( size_t t = 0; t \u003C 16; ++t) {\n        threads.emplace_back( []() {\n            for (size_t i = 0; i \u003C 10'000; ++i) {\n                FAIL();\n            }\n        } );\n    }\n}\n",[21,1134,1135,1146,1164,1190,1198,1224,1231,1235,1239,1243],{"__ignoreMap":242},[246,1136,1137,1139,1141,1144],{"class":248,"line":249},[246,1138,23],{"class":252},[246,1140,256],{"class":255},[246,1142,1143],{"class":259},"\"FAIL\u002FSKIP in spawned thread kills the process\"",[246,1145,263],{"class":255},[246,1147,1148,1150,1152,1154,1156,1158,1160,1162],{"class":248,"line":266},[246,1149,269],{"class":252},[246,1151,272],{"class":255},[246,1153,275],{"class":252},[246,1155,278],{"class":255},[246,1157,281],{"class":252},[246,1159,272],{"class":255},[246,1161,286],{"class":252},[246,1163,289],{"class":255},[246,1165,1166,1168,1170,1172,1174,1176,1178,1180,1182,1184,1186,1188],{"class":248,"line":292},[246,1167,296],{"class":295},[246,1169,299],{"class":255},[246,1171,302],{"class":295},[246,1173,305],{"class":255},[246,1175,308],{"class":295},[246,1177,312],{"class":311},[246,1179,315],{"class":255},[246,1181,278],{"class":295},[246,1183,320],{"class":311},[246,1185,323],{"class":255},[246,1187,326],{"class":295},[246,1189,329],{"class":255},[246,1191,1192,1194,1196],{"class":248,"line":332},[246,1193,335],{"class":255},[246,1195,338],{"class":252},[246,1197,341],{"class":255},[246,1199,1200,1202,1204,1206,1208,1210,1212,1214,1216,1218,1220,1222],{"class":248,"line":344},[246,1201,347],{"class":295},[246,1203,350],{"class":255},[246,1205,302],{"class":295},[246,1207,355],{"class":255},[246,1209,308],{"class":295},[246,1211,312],{"class":311},[246,1213,362],{"class":255},[246,1215,278],{"class":295},[246,1217,367],{"class":311},[246,1219,323],{"class":255},[246,1221,326],{"class":295},[246,1223,374],{"class":255},[246,1225,1226,1229],{"class":248,"line":377},[246,1227,1228],{"class":252},"                FAIL",[246,1230,1102],{"class":255},[246,1232,1233],{"class":248,"line":391},[246,1234,406],{"class":255},[246,1236,1237],{"class":248,"line":403},[246,1238,412],{"class":255},[246,1240,1241],{"class":248,"line":409},[246,1242,418],{"class":255},[246,1244,1245],{"class":248,"line":415},[246,1246,443],{"class":255},[13,1248,1249,1250,1252,1253,24,1255,1257],{},"As with failing ",[21,1251,27],{},", both ",[21,1254,188],{},[21,1256,185],{}," in spawned threads\nterminate the process.",[138,1259,1261,24,1263],{"id":1260},"static_require-and-static_check",[21,1262,91],{},[21,1264,94],{},[13,1266,1267,1268,36,1270,36,1273,1275,1276,1279],{},"All of ",[21,1269,91],{},[21,1271,1272],{},"STATIC_REQUIRE_FALSE",[21,1274,94],{},", and\n",[21,1277,1278],{},"STATIC_CHECK_FALSE"," are thread safe in the delayed evaluation configuration.",[138,1281,100],{"id":1282},"fatal-errors-and-multiple-threads",[13,1284,1285,1286,959],{},"By default, Catch2 tries to catch fatal errors (POSIX signals\u002FWindows\nStructured Exceptions) and report something useful to the user. This\nalways happened on a best-effort basis, but in presence of multiple\nthreads and locks the chance of it working decreases. If this starts\nbeing an issue for you, ",[45,1287,1289],{"href":1288},"\u002Fdocs\u002Fconfiguration\u002F#other-toggles","you can disable it",[138,1291,106],{"id":1292},"performance-overhead",[13,1294,1295],{},"In the worst case, which is optimized build and assertions using the\nfast path for successful assertions, the performance overhead of using\nthe thread-safe assertion implementation can reach 40%. In other cases,\nthe overhead will be smaller, between 4% and 20%.",[1297,1298,1299],"style",{},"html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":242,"searchDepth":266,"depth":266,"links":1301},[1302,1303,1304,1305,1314,1316,1317],{"id":140,"depth":266,"text":65},{"id":172,"depth":266,"text":71},{"id":205,"depth":266,"text":77},{"id":83,"depth":266,"text":83,"children":1306},[1307,1309,1311,1312,1313],{"id":229,"depth":292,"text":1308},"REQUIRE from the main thread, CHECK from spawned threads",{"id":449,"depth":292,"text":1310},"REQUIRE from spawned threads",{"id":704,"depth":292,"text":705},{"id":962,"depth":292,"text":963},{"id":1128,"depth":292,"text":1129},{"id":1260,"depth":266,"text":1315},"STATIC_REQUIRE and STATIC_CHECK",{"id":1282,"depth":266,"text":100},{"id":1292,"depth":266,"text":106},"md",{},"\u002Fdocs\u002Fthread-safety",{"title":5,"description":242},"thread-safety","docs\u002Fthread-safety.md","docs\u002Fthread-safety","KSr7bTtWJWi0TCFsxIRD7yw_tvEsRfKwG-76VWu2Ml8",1794961593868]