diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-10-14 17:53:06 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-10-14 17:57:29 +0000 |
commit | 433d1fccf19f4fd390b54ac7c149c17529a37e6a (patch) | |
tree | e31c4021dfc3571ed21849af02e703d00b564a21 /staging_vespalib | |
parent | 1ad0641192b439447750c49fee0ca6255d4601fd (diff) |
GC unuse code and use std::mutex/std:condition_variable over vespalib::Monitor
Diffstat (limited to 'staging_vespalib')
-rw-r--r-- | staging_vespalib/src/tests/singleexecutor/singleexecutor_test.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/staging_vespalib/src/tests/singleexecutor/singleexecutor_test.cpp b/staging_vespalib/src/tests/singleexecutor/singleexecutor_test.cpp index 5dacaa5d204..622c9b9985f 100644 --- a/staging_vespalib/src/tests/singleexecutor/singleexecutor_test.cpp +++ b/staging_vespalib/src/tests/singleexecutor/singleexecutor_test.cpp @@ -28,7 +28,8 @@ TEST("test that all tasks are executed") { } void verifyResizeTaskLimit(bool up) { - Monitor lock; + std::mutex lock; + std::condition_variable cond; std::atomic<uint64_t> started(0); std::atomic<uint64_t> allowed(0); SingleExecutor executor(10); @@ -38,11 +39,11 @@ void verifyResizeTaskLimit(bool up) { EXPECT_NOT_EQUAL(16u, roundedTaskLimit); for (uint64_t i(0); i < 10; i++) { - executor.execute(makeLambdaTask([&lock, &started, &allowed] { + executor.execute(makeLambdaTask([&lock, &cond, &started, &allowed] { started++; - MonitorGuard guard(lock); + std::unique_lock guard(lock); while (allowed < started) { - guard.wait(1ms); + cond.wait_for(guard, 1ms); } })); } @@ -58,11 +59,11 @@ void verifyResizeTaskLimit(bool up) { while (started < 10); EXPECT_EQUAL(10u, started); EXPECT_EQUAL(16u, executor.getTaskLimit()); - executor.execute(makeLambdaTask([&lock, &started, &allowed] { + executor.execute(makeLambdaTask([&lock, &cond, &started, &allowed] { started++; - MonitorGuard guard(lock); + std::unique_lock guard(lock); while (allowed < started) { - guard.wait(1ms); + cond.wait_for(guard, 1ms); } })); while (started < 11); |