diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-01-31 15:14:57 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-01-31 17:36:43 +0000 |
commit | 2503a877f21838e66e873f839a5b6fd0c38abfab (patch) | |
tree | 966ae9d7757aa58e7bff4aaa4b9b45b5f6668329 /vespalib/src/tests/executor | |
parent | 5ac0d0b71749c7555167c3c3906ff6843bf178f0 (diff) |
Use vespalib::duration for timeouts
Diffstat (limited to 'vespalib/src/tests/executor')
-rw-r--r-- | vespalib/src/tests/executor/blockingthreadstackexecutor_test.cpp | 14 | ||||
-rw-r--r-- | vespalib/src/tests/executor/stress_test.cpp | 1 | ||||
-rw-r--r-- | vespalib/src/tests/executor/threadstackexecutor_test.cpp | 4 |
3 files changed, 10 insertions, 9 deletions
diff --git a/vespalib/src/tests/executor/blockingthreadstackexecutor_test.cpp b/vespalib/src/tests/executor/blockingthreadstackexecutor_test.cpp index 46db619516a..a0ef200ab83 100644 --- a/vespalib/src/tests/executor/blockingthreadstackexecutor_test.cpp +++ b/vespalib/src/tests/executor/blockingthreadstackexecutor_test.cpp @@ -1,6 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> - +#include <vespa/vespalib/testkit/time_bomb.h> #include <vespa/vespalib/util/blockingthreadstackexecutor.h> #include <vespa/vespalib/util/executor.h> #include <vespa/vespalib/util/backtrace.h> @@ -8,7 +8,7 @@ using namespace vespalib; -constexpr int msWait = 30000; +constexpr vespalib::duration waitTime = 30s; class MyTask : public Executor::Task { @@ -21,8 +21,8 @@ public: : _entryGate(entryGate), _exitLatch(exitLatch) {} - virtual void run() override { - _entryGate.await(msWait); + void run() override { + _entryGate.await(waitTime); _exitLatch.countDown(); } static Task::UP create(Gate &entryGate, CountDownLatch &exitLatch) { @@ -64,14 +64,14 @@ struct Fixture workersEntryGate.countDown(); } void waitForWorkers() { - workersExitLatch.await(msWait); + workersExitLatch.await(waitTime); } void assertExecuteIsBlocked() { - blockedExecuteGate.await(10); + blockedExecuteGate.await(10ms); EXPECT_EQUAL(1u, blockedExecuteGate.getCount()); } void waitForExecuteIsFinished() { - blockedExecuteGate.await(msWait); + blockedExecuteGate.await(waitTime); EXPECT_EQUAL(0u, blockedExecuteGate.getCount()); } ThreadUP blockedExecuteThread() { diff --git a/vespalib/src/tests/executor/stress_test.cpp b/vespalib/src/tests/executor/stress_test.cpp index 615e7addfd5..01873fa0480 100644 --- a/vespalib/src/tests/executor/stress_test.cpp +++ b/vespalib/src/tests/executor/stress_test.cpp @@ -4,6 +4,7 @@ #include <vespa/vespalib/util/executor.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/locale/c.h> +#include <thread> using namespace vespalib; using namespace std::literals; diff --git a/vespalib/src/tests/executor/threadstackexecutor_test.cpp b/vespalib/src/tests/executor/threadstackexecutor_test.cpp index b43a75f8244..e860a25c83c 100644 --- a/vespalib/src/tests/executor/threadstackexecutor_test.cpp +++ b/vespalib/src/tests/executor/threadstackexecutor_test.cpp @@ -147,9 +147,9 @@ TEST_MT_F("require that threads can wait for a specific task count", 7, WaitStat if (next_done < f1.block_task.size()) { f1.block_task[f1.block_task.size() - 1 - next_done].countDown(); } - EXPECT_TRUE(f1.wait_done[next_done].await(25000)); + EXPECT_TRUE(f1.wait_done[next_done].await(25s)); for (size_t i = 0; i < next_done; ++i) { - EXPECT_TRUE(!f1.wait_done[i].await(20)); + EXPECT_TRUE(!f1.wait_done[i].await(20ms)); } } } else { |