File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -76,19 +76,27 @@ TEST(Log, inMemLogInANamedThread) {
7676
7777#include < chrono>
7878
79- TEST (Log, concurrencyOrchestration) {
79+ void millisleep (unsigned milliseconds) {
80+ // Pause the current thread for a given number of milliseconds
81+ // in multiple 1ms shots. This gives the scheduler higher probability
82+ // of waking up the concurrent thread at the right time under high load.
8083 using namespace std ::chrono_literals;
8184
85+ for ( unsigned i = 0 ; i < milliseconds; ++i )
86+ std::this_thread::sleep_for (1ms);
87+ }
88+
89+ TEST (Log, concurrencyOrchestration) {
8290 const auto oddFlow = [](){
83- std::this_thread::sleep_for (100ms );
91+ millisleep ( 10 );
8492 log_debug (" Humpty Dumpty sat on a wall." );
85- std::this_thread::sleep_for (100ms );
93+ millisleep ( 10 );
8694 log_debug (" All the king's horses and all the king's men" );
8795 };
8896
8997 const auto evenFlow = [](){
9098 log_debug (" Humpty Dumpty had a great fall." );
91- std::this_thread::sleep_for (150ms );
99+ millisleep ( 15 );
92100 log_debug (" Couldn't put Humpty together again." );
93101 };
94102
You can’t perform that action at this time.
0 commit comments