aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-01-31 15:14:57 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-01-31 17:36:43 +0000
commit2503a877f21838e66e873f839a5b6fd0c38abfab (patch)
tree966ae9d7757aa58e7bff4aaa4b9b45b5f6668329
parent5ac0d0b71749c7555167c3c3906ff6843bf178f0 (diff)
Use vespalib::duration for timeouts
-rw-r--r--config/src/tests/configfetcher/configfetcher.cpp1
-rw-r--r--config/src/tests/configholder/configholder.cpp1
-rw-r--r--config/src/tests/configretriever/configretriever.cpp7
-rw-r--r--config/src/tests/frt/frt.cpp6
-rw-r--r--config/src/tests/subscriber/subscriber.cpp7
-rw-r--r--config/src/tests/subscription/subscription.cpp1
-rw-r--r--documentapi/src/tests/policies/policies_test.cpp2
-rw-r--r--eval/src/tests/eval/compile_cache/compile_cache_test.cpp2
-rw-r--r--fnet/src/tests/connect/connect_test.cpp3
-rw-r--r--fnet/src/tests/frt/rpc/detach_return_invoke.cpp1
-rw-r--r--fnet/src/tests/sync_execute/sync_execute.cpp1
-rw-r--r--messagebus/src/tests/context/context.cpp1
-rw-r--r--messagebus/src/tests/messagebus/messagebus.cpp1
-rw-r--r--messagebus/src/tests/serviceaddress/serviceaddress.cpp1
-rw-r--r--messagebus/src/tests/slobrok/slobrok.cpp2
-rw-r--r--messagebus/src/tests/sourcesession/sourcesession.cpp1
-rw-r--r--messagebus/src/tests/throttling/throttling.cpp1
-rw-r--r--messagebus_test/src/tests/trace/trace.cpp1
-rw-r--r--searchcore/src/tests/proton/attribute/attributeflush_test.cpp1
-rw-r--r--searchcore/src/tests/proton/attribute/exclusive_attribute_read_accessor/exclusive_attribute_read_accessor_test.cpp2
-rw-r--r--searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp40
-rw-r--r--searchcore/src/tests/proton/documentdb/job_tracked_maintenance_job/job_tracked_maintenance_job_test.cpp8
-rw-r--r--searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp45
-rw-r--r--searchcore/src/tests/proton/flushengine/flushengine_test.cpp6
-rw-r--r--searchcore/src/tests/proton/matching/docid_range_scheduler/docid_range_scheduler_test.cpp3
-rw-r--r--searchcore/src/tests/proton/metrics/documentdb_job_trackers/documentdb_job_trackers_test.cpp1
-rw-r--r--searchcore/src/tests/proton/metrics/job_tracked_flush/job_tracked_flush_test.cpp24
-rw-r--r--searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/eventlogger.cpp33
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/eventlogger.h13
-rw-r--r--searchcore/src/vespa/searchcore/proton/docsummary/summarymanagerinitializer.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/reprocessing/reprocess_documents_task.cpp7
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/transactionlogmanager.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/simple_job_tracker.h2
-rw-r--r--searchlib/src/tests/transactionlog/translogclient_test.cpp1
-rw-r--r--slobrok/src/tests/configure/configure.cpp1
-rw-r--r--slobrok/src/tests/mirrorapi/mirrorapi.cpp1
-rw-r--r--slobrok/src/tests/registerapi/registerapi.cpp1
-rw-r--r--slobrok/src/tests/standalone/standalone.cpp1
-rw-r--r--staging_vespalib/src/tests/clock/clock_test.cpp1
-rw-r--r--staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp1
-rw-r--r--staging_vespalib/src/tests/timer/timer_test.cpp12
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/adaptive_sequenced_executor.h1
-rw-r--r--vbench/src/apps/vbench/vbench.cpp4
-rw-r--r--vbench/src/tests/time_queue/time_queue_test.cpp6
-rw-r--r--vespalib/src/tests/barrier/barrier_test.cpp12
-rw-r--r--vespalib/src/tests/benchmark_timer/benchmark_timer_test.cpp1
-rw-r--r--vespalib/src/tests/executor/blockingthreadstackexecutor_test.cpp14
-rw-r--r--vespalib/src/tests/executor/stress_test.cpp1
-rw-r--r--vespalib/src/tests/executor/threadstackexecutor_test.cpp4
-rw-r--r--vespalib/src/tests/latch/latch_test.cpp9
-rw-r--r--vespalib/src/tests/net/async_resolver/async_resolver_test.cpp1
-rw-r--r--vespalib/src/tests/net/crypto_socket/crypto_socket_test.cpp1
-rw-r--r--vespalib/src/tests/net/selector/selector_test.cpp1
-rw-r--r--vespalib/src/tests/net/send_fd/send_fd_test.cpp2
-rw-r--r--vespalib/src/tests/net/socket/socket_test.cpp2
-rw-r--r--vespalib/src/tests/net/sync_crypto_socket/sync_crypto_socket_test.cpp1
-rw-r--r--vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp4
-rw-r--r--vespalib/src/tests/portal/handle_manager/handle_manager_test.cpp9
-rw-r--r--vespalib/src/tests/portal/portal_test.cpp11
-rw-r--r--vespalib/src/tests/portal/reactor/reactor_test.cpp9
-rw-r--r--vespalib/src/tests/rendezvous/rendezvous_test.cpp6
-rw-r--r--vespalib/src/tests/simple_thread_bundle/simple_thread_bundle_test.cpp5
-rw-r--r--vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp1
-rw-r--r--vespalib/src/tests/sync/sync_test.cpp8
-rw-r--r--vespalib/src/tests/testkit-time_bomb/testkit-time_bomb_test.cpp1
-rw-r--r--vespalib/src/tests/thread/thread_test.cpp1
-rw-r--r--vespalib/src/tests/time/time_box_test.cpp1
-rw-r--r--vespalib/src/tests/websocket/websocket_test.cpp5
-rw-r--r--vespalib/src/vespa/vespalib/testkit/test_kit.h1
-rw-r--r--vespalib/src/vespa/vespalib/testkit/time_bomb.cpp4
-rw-r--r--vespalib/src/vespa/vespalib/util/count_down_latch.h7
-rw-r--r--vespamalloc/src/tests/allocfree/allocfree.cpp1
-rw-r--r--vespamalloc/src/tests/allocfree/linklist.cpp2
78 files changed, 196 insertions, 197 deletions
diff --git a/config/src/tests/configfetcher/configfetcher.cpp b/config/src/tests/configfetcher/configfetcher.cpp
index 508322bb74e..0cff6208873 100644
--- a/config/src/tests/configfetcher/configfetcher.cpp
+++ b/config/src/tests/configfetcher/configfetcher.cpp
@@ -5,6 +5,7 @@
#include <vespa/vespalib/util/exception.h>
#include "config-my.h"
#include <atomic>
+#include <thread>
using namespace config;
diff --git a/config/src/tests/configholder/configholder.cpp b/config/src/tests/configholder/configholder.cpp
index d69ad8022f9..1f2c1f27df6 100644
--- a/config/src/tests/configholder/configholder.cpp
+++ b/config/src/tests/configholder/configholder.cpp
@@ -1,6 +1,7 @@
// 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/config/common/configholder.h>
+#include <thread>
using namespace config;
diff --git a/config/src/tests/configretriever/configretriever.cpp b/config/src/tests/configretriever/configretriever.cpp
index d4ebe2da994..c8157ff7c16 100644
--- a/config/src/tests/configretriever/configretriever.cpp
+++ b/config/src/tests/configretriever/configretriever.cpp
@@ -1,5 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include "config-bootstrap.h"
+#include "config-foo.h"
+#include "config-bar.h"
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/config/print.h>
@@ -11,9 +14,7 @@
#include <vespa/config/subscription/configsubscription.h>
#include <vespa/config/subscription/sourcespec.h>
#include <vespa/config/common/exceptions.h>
-#include "config-bootstrap.h"
-#include "config-foo.h"
-#include "config-bar.h"
+#include <thread>
#include <atomic>
using namespace config;
diff --git a/config/src/tests/frt/frt.cpp b/config/src/tests/frt/frt.cpp
index 6cffe079dae..cb09b8f7254 100644
--- a/config/src/tests/frt/frt.cpp
+++ b/config/src/tests/frt/frt.cpp
@@ -1,5 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include "config-my.h"
+#include "config-bar.h"
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/config/common/iconfigholder.h>
#include <vespa/config/common/trace.h>
@@ -15,9 +17,7 @@
#include <vespa/fnet/frt/supervisor.h>
#include <vespa/config/frt/protocol.h>
#include <lz4.h>
-#include "config-my.h"
-#include "config-bar.h"
-
+#include <thread>
using namespace config;
using namespace vespalib;
diff --git a/config/src/tests/subscriber/subscriber.cpp b/config/src/tests/subscriber/subscriber.cpp
index 9d5aeddaf37..d58699f26e0 100644
--- a/config/src/tests/subscriber/subscriber.cpp
+++ b/config/src/tests/subscriber/subscriber.cpp
@@ -1,13 +1,14 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include "config-foo.h"
+#include "config-bar.h"
+#include "config-baz.h"
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/config/config.h>
#include <vespa/config/common/misc.h>
#include <vespa/config/common/configholder.h>
#include <vespa/config/subscription/configsubscription.h>
#include <vespa/config/common/exceptions.h>
-#include "config-foo.h"
-#include "config-bar.h"
-#include "config-baz.h"
+#include <thread>
using namespace config;
using namespace vespalib;
diff --git a/config/src/tests/subscription/subscription.cpp b/config/src/tests/subscription/subscription.cpp
index 9583111a2f7..7a5fccec019 100644
--- a/config/src/tests/subscription/subscription.cpp
+++ b/config/src/tests/subscription/subscription.cpp
@@ -4,6 +4,7 @@
#include <vespa/config/common/configholder.h>
#include <vespa/config/subscription/configsubscription.h>
#include <config-my.h>
+#include <thread>
using namespace config;
using namespace std::chrono_literals;
diff --git a/documentapi/src/tests/policies/policies_test.cpp b/documentapi/src/tests/policies/policies_test.cpp
index 02bd6b297d0..c80e1221eba 100644
--- a/documentapi/src/tests/policies/policies_test.cpp
+++ b/documentapi/src/tests/policies/policies_test.cpp
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "testframe.h"
-
#include <vespa/documentapi/documentapi.h>
#include <vespa/documentapi/messagebus/policies/andpolicy.h>
#include <vespa/documentapi/messagebus/policies/contentpolicy.h>
@@ -25,6 +24,7 @@
#include <vespa/document/update/documentupdate.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/stringfmt.h>
+#include <thread>
#include <vespa/log/log.h>
LOG_SETUP("policies_test");
diff --git a/eval/src/tests/eval/compile_cache/compile_cache_test.cpp b/eval/src/tests/eval/compile_cache/compile_cache_test.cpp
index 5dea89b3a63..a0c71e2f756 100644
--- a/eval/src/tests/eval/compile_cache/compile_cache_test.cpp
+++ b/eval/src/tests/eval/compile_cache/compile_cache_test.cpp
@@ -1,5 +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/eval/eval/llvm/compile_cache.h>
#include <vespa/eval/eval/key_gen.h>
#include <vespa/eval/eval/test/eval_spec.h>
@@ -7,7 +8,6 @@
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <vespa/vespalib/util/blockingthreadstackexecutor.h>
#include <vespa/vespalib/util/stringfmt.h>
-#include <thread>
#include <set>
using namespace vespalib;
diff --git a/fnet/src/tests/connect/connect_test.cpp b/fnet/src/tests/connect/connect_test.cpp
index 2b4a2bbe9f0..50722e7d16e 100644
--- a/fnet/src/tests/connect/connect_test.cpp
+++ b/fnet/src/tests/connect/connect_test.cpp
@@ -1,6 +1,7 @@
// 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/fnet/transport.h>
#include <vespa/fnet/transport_thread.h>
#include <vespa/fnet/simplepacketstreamer.h>
@@ -13,7 +14,7 @@
using namespace vespalib;
-int short_time = 20; // ms
+constexpr vespalib::duration short_time = 20ms;
struct BlockingHostResolver : public AsyncResolver::HostResolver {
AsyncResolver::SimpleHostResolver resolver;
diff --git a/fnet/src/tests/frt/rpc/detach_return_invoke.cpp b/fnet/src/tests/frt/rpc/detach_return_invoke.cpp
index 68bd58d2f82..8d65c65f768 100644
--- a/fnet/src/tests/frt/rpc/detach_return_invoke.cpp
+++ b/fnet/src/tests/frt/rpc/detach_return_invoke.cpp
@@ -5,6 +5,7 @@
#include <vespa/fnet/frt/rpcrequest.h>
#include <vespa/fnet/frt/invoker.h>
#include <vespa/vespalib/util/stringfmt.h>
+#include <thread>
struct Receptor : public FRT_IRequestWait
{
diff --git a/fnet/src/tests/sync_execute/sync_execute.cpp b/fnet/src/tests/sync_execute/sync_execute.cpp
index 55a898496ae..d577b5b7e92 100644
--- a/fnet/src/tests/sync_execute/sync_execute.cpp
+++ b/fnet/src/tests/sync_execute/sync_execute.cpp
@@ -1,5 +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/util/gate.h>
#include <vespa/fnet/transport.h>
#include <vespa/fnet/iexecutable.h>
#include <vespa/fastos/thread.h>
diff --git a/messagebus/src/tests/context/context.cpp b/messagebus/src/tests/context/context.cpp
index 713e01cae73..dd734cbbb26 100644
--- a/messagebus/src/tests/context/context.cpp
+++ b/messagebus/src/tests/context/context.cpp
@@ -10,6 +10,7 @@
#include <vespa/messagebus/testlib/simplemessage.h>
#include <vespa/messagebus/testlib/testserver.h>
#include <vespa/vespalib/testkit/testapp.h>
+#include <thread>
using namespace mbus;
diff --git a/messagebus/src/tests/messagebus/messagebus.cpp b/messagebus/src/tests/messagebus/messagebus.cpp
index 367bfc997d0..259c24ad176 100644
--- a/messagebus/src/tests/messagebus/messagebus.cpp
+++ b/messagebus/src/tests/messagebus/messagebus.cpp
@@ -13,6 +13,7 @@
#include <vespa/messagebus/testlib/testserver.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/stringfmt.h>
+#include <thread>
using namespace mbus;
diff --git a/messagebus/src/tests/serviceaddress/serviceaddress.cpp b/messagebus/src/tests/serviceaddress/serviceaddress.cpp
index c5d07bc437a..0ecba42bf4e 100644
--- a/messagebus/src/tests/serviceaddress/serviceaddress.cpp
+++ b/messagebus/src/tests/serviceaddress/serviceaddress.cpp
@@ -4,6 +4,7 @@
#include <vespa/messagebus/testlib/slobrok.h>
#include <vespa/messagebus/testlib/testserver.h>
#include <vespa/messagebus/network/rpcservice.h>
+#include <thread>
using namespace mbus;
diff --git a/messagebus/src/tests/slobrok/slobrok.cpp b/messagebus/src/tests/slobrok/slobrok.cpp
index 439ee0b23b5..a9e6d0f4847 100644
--- a/messagebus/src/tests/slobrok/slobrok.cpp
+++ b/messagebus/src/tests/slobrok/slobrok.cpp
@@ -5,8 +5,8 @@
#include <vespa/slobrok/sbmirror.h>
#include <vespa/messagebus/network/rpcnetwork.h>
#include <vespa/messagebus/network/rpcnetworkparams.h>
-
#include <vespa/vespalib/util/host_name.h>
+#include <thread>
using slobrok::api::IMirrorAPI;
diff --git a/messagebus/src/tests/sourcesession/sourcesession.cpp b/messagebus/src/tests/sourcesession/sourcesession.cpp
index 3ffe0f8e19d..25d75aa180c 100644
--- a/messagebus/src/tests/sourcesession/sourcesession.cpp
+++ b/messagebus/src/tests/sourcesession/sourcesession.cpp
@@ -17,6 +17,7 @@
#include <vespa/messagebus/testlib/slobrok.h>
#include <vespa/messagebus/testlib/testserver.h>
#include <vespa/vespalib/testkit/testapp.h>
+#include <thread>
using namespace mbus;
diff --git a/messagebus/src/tests/throttling/throttling.cpp b/messagebus/src/tests/throttling/throttling.cpp
index a23e0b61550..e11aabfd0ba 100644
--- a/messagebus/src/tests/throttling/throttling.cpp
+++ b/messagebus/src/tests/throttling/throttling.cpp
@@ -13,6 +13,7 @@
#include <vespa/messagebus/testlib/simplemessage.h>
#include <vespa/messagebus/testlib/simplereply.h>
#include <vespa/messagebus/testlib/testserver.h>
+#include <thread>
using namespace mbus;
diff --git a/messagebus_test/src/tests/trace/trace.cpp b/messagebus_test/src/tests/trace/trace.cpp
index 1ab30303d2c..a5e9251f9cc 100644
--- a/messagebus_test/src/tests/trace/trace.cpp
+++ b/messagebus_test/src/tests/trace/trace.cpp
@@ -19,6 +19,7 @@
#include <vespa/messagebus/testlib/simplereply.h>
#include <vespa/messagebus/testlib/simpleprotocol.h>
#include <iostream>
+#include <thread>
#include <vespa/log/log.h>
LOG_SETUP("trace_test");
diff --git a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
index 8a814e25bd5..d6c40b0d70d 100644
--- a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
@@ -18,6 +18,7 @@
#include <vespa/vespalib/util/foreground_thread_executor.h>
#include <vespa/vespalib/util/foregroundtaskexecutor.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
+#include <thread>
#include <vespa/log/log.h>
LOG_SETUP("attributeflush_test");
diff --git a/searchcore/src/tests/proton/attribute/exclusive_attribute_read_accessor/exclusive_attribute_read_accessor_test.cpp b/searchcore/src/tests/proton/attribute/exclusive_attribute_read_accessor/exclusive_attribute_read_accessor_test.cpp
index e284f5ed1d9..cb64a1a59d8 100644
--- a/searchcore/src/tests/proton/attribute/exclusive_attribute_read_accessor/exclusive_attribute_read_accessor_test.cpp
+++ b/searchcore/src/tests/proton/attribute/exclusive_attribute_read_accessor/exclusive_attribute_read_accessor_test.cpp
@@ -40,7 +40,7 @@ TEST_F("require that attribute write thread is blocked while guard is held", Fix
ReadGuard::UP guard = f.accessor.takeGuard();
Gate gate;
f.writer->execute(f.writer->getExecutorIdFromName(f.attribute->getNamePrefix()), [&gate]() { gate.countDown(); });
- bool reachedZero = gate.await(100);
+ bool reachedZero = gate.await(100ms);
EXPECT_FALSE(reachedZero);
EXPECT_EQUAL(1u, gate.getCount());
diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
index 1127191a1a2..8840d4778e0 100644
--- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
@@ -78,20 +78,20 @@ struct Rendezvous {
vespalib::Gate gone;
typedef std::unique_ptr<Rendezvous> UP;
Rendezvous() : enter(), leave(), gone() {}
- bool run(uint32_t timeout = 80000) {
+ bool run(vespalib::duration timeout = 80s) {
enter.countDown();
bool retval = leave.await(timeout);
gone.countDown();
return retval;
}
- bool waitForEnter(uint32_t timeout = 80000) {
+ bool waitForEnter(vespalib::duration timeout = 80s) {
return enter.await(timeout);
}
- bool leaveAndWait(uint32_t timeout = 80000) {
+ bool leaveAndWait(vespalib::duration timeout = 80s) {
leave.countDown();
return gone.await(timeout);
}
- bool await(uint32_t timeout = 80000) {
+ bool await(vespalib::duration timeout = 80s) {
if (waitForEnter(timeout)) {
return leaveAndWait(timeout);
}
@@ -373,7 +373,7 @@ struct FeedTokenContext {
FeedTokenContext();
~FeedTokenContext();
- bool await(uint32_t timeout = 80000) { return transport.gate.await(timeout); }
+ bool await(vespalib::duration timeout = 80s) { return transport.gate.await(timeout); }
const Result *getResult() {
if (transport.result.get()) {
return transport.result.get();
@@ -399,36 +399,6 @@ struct PutContext {
{}
};
-
-struct PutHandler {
- FeedHandler &handler;
- DocBuilder &builder;
- Timestamp timestamp;
- std::vector<PutContext::SP> puts;
- PutHandler(FeedHandler &fh, DocBuilder &db) :
- handler(fh),
- builder(db),
- timestamp(0),
- puts()
- {}
- void put(const vespalib::string &docId) {
- PutContext::SP pc(new PutContext(docId, builder));
- FeedOperation::UP op(new PutOperation(pc->docCtx.bucketId, timestamp, pc->docCtx.doc));
- handler.handleOperation(pc->tokenCtx.token, std::move(op));
- timestamp = Timestamp(timestamp + 1);
- puts.push_back(pc);
- }
- bool await(uint32_t timeout = 80000) {
- for (const auto & put : puts) {
- if (!put->tokenCtx.await(timeout)) {
- return false;
- }
- }
- return true;
- }
-};
-
-
struct MyTlsWriter : TlsWriter {
int store_count;
int erase_count;
diff --git a/searchcore/src/tests/proton/documentdb/job_tracked_maintenance_job/job_tracked_maintenance_job_test.cpp b/searchcore/src/tests/proton/documentdb/job_tracked_maintenance_job/job_tracked_maintenance_job_test.cpp
index 2bde5761aea..c12b91c4c1e 100644
--- a/searchcore/src/tests/proton/documentdb/job_tracked_maintenance_job/job_tracked_maintenance_job_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/job_tracked_maintenance_job/job_tracked_maintenance_job_test.cpp
@@ -24,7 +24,7 @@ getGateVector(size_t size)
{
GateVector retval;
for (size_t i = 0; i < size; ++i) {
- retval.push_back(GateUP(new Gate()));
+ retval.push_back(std::make_unique<Gate>());
}
return retval;
}
@@ -46,7 +46,7 @@ struct MyMaintenanceJob : public IBlockableMaintenanceJob
void unBlock(BlockedReason) override { _blocked = false; }
bool isBlocked() const override { return _blocked; }
bool run() override {
- _runGates[_runIdx++]->await(5000);
+ _runGates[_runIdx++]->await(5s);
return _runIdx == _runGates.size();
}
};
@@ -82,10 +82,10 @@ struct Fixture
}
void runJobAndWait(size_t runIdx, size_t startedGateCount, size_t endedGateCount) {
_exec.execute(vespalib::makeLambdaTask([this]() { runJob(); }));
- _tracker->_started.await(5000);
+ _tracker->_started.await(5s);
assertTracker(startedGateCount, endedGateCount);
_myJob->_runGates[runIdx]->countDown();
- _runGates[runIdx]->await(5000);
+ _runGates[runIdx]->await(5s);
}
};
diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
index c6ffa167dbf..44afe1ddd75 100644
--- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
@@ -72,8 +72,7 @@ using BlockedReason = IBlockableMaintenanceJob::BlockedReason;
typedef BucketId::List BucketIdVector;
typedef std::set<BucketId> BucketIdSet;
-constexpr int TIMEOUT_MS = 60000;
-constexpr vespalib::duration TIMEOUT_SEC = 60s;
+constexpr vespalib::duration TIMEOUT = 60s;
namespace {
@@ -947,14 +946,14 @@ TEST_F("require that bucket move controller is active", MaintenanceControllerFix
EXPECT_EQUAL(5u, f._notReady.getNumUsedLids());
EXPECT_EQUAL(5u, f._notReady.getDocumentCount());
f.startMaintenance();
- ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC));
+ ASSERT_TRUE(f._executor.waitIdle(TIMEOUT));
EXPECT_EQUAL(0u, f._ready.getNumUsedLids());
EXPECT_EQUAL(0u, f._ready.getDocumentCount());
EXPECT_EQUAL(10u, f._notReady.getNumUsedLids());
EXPECT_EQUAL(10u, f._notReady.getDocumentCount());
f._calc->addReady(bucketId1);
f.notifyClusterStateChanged();
- ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC));
+ ASSERT_TRUE(f._executor.waitIdle(TIMEOUT));
EXPECT_EQUAL(3u, f._ready.getNumUsedLids());
EXPECT_EQUAL(3u, f._ready.getDocumentCount());
EXPECT_EQUAL(7u, f._notReady.getNumUsedLids());
@@ -963,13 +962,13 @@ TEST_F("require that bucket move controller is active", MaintenanceControllerFix
f._calc->addReady(bucketId2);
f._calc->addReady(bucketId4);
f.notifyClusterStateChanged();
- ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC));
+ ASSERT_TRUE(f._executor.waitIdle(TIMEOUT));
EXPECT_EQUAL(6u, f._ready.getNumUsedLids());
EXPECT_EQUAL(6u, f._ready.getDocumentCount());
EXPECT_EQUAL(4u, f._notReady.getNumUsedLids());
EXPECT_EQUAL(4u, f._notReady.getDocumentCount());
frozen2.reset();
- ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC));
+ ASSERT_TRUE(f._executor.waitIdle(TIMEOUT));
EXPECT_EQUAL(8u, f._ready.getNumUsedLids());
EXPECT_EQUAL(8u, f._ready.getDocumentCount());
EXPECT_EQUAL(2u, f._notReady.getNumUsedLids());
@@ -997,14 +996,14 @@ TEST_F("require that document pruner is active", MaintenanceControllerFixture)
EXPECT_EQUAL(10u, f._removed.getNumUsedLids());
EXPECT_EQUAL(10u, f._removed.getDocumentCount());
f.startMaintenance();
- ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC));
+ ASSERT_TRUE(f._executor.waitIdle(TIMEOUT));
EXPECT_EQUAL(10u, f._removed.getNumUsedLids());
EXPECT_EQUAL(10u, f._removed.getDocumentCount());
MyFrozenBucket::UP frozen3(new MyFrozenBucket(f._mc, bucketId3));
f.setPruneConfig(DocumentDBPruneRemovedDocumentsConfig(200ms, 900s));
for (uint32_t i = 0; i < 6; ++i) {
std::this_thread::sleep_for(100ms);
- ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC));
+ ASSERT_TRUE(f._executor.waitIdle(TIMEOUT));
if (f._removed.getNumUsedLids() != 10u)
break;
}
@@ -1013,7 +1012,7 @@ TEST_F("require that document pruner is active", MaintenanceControllerFixture)
frozen3.reset();
for (uint32_t i = 0; i < 600; ++i) {
std::this_thread::sleep_for(100ms);
- ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC));
+ ASSERT_TRUE(f._executor.waitIdle(TIMEOUT));
if (f._removed.getNumUsedLids() != 10u)
break;
}
@@ -1075,7 +1074,7 @@ TEST_F("require that active bucket is not moved until de-activated", Maintenance
EXPECT_EQUAL(5u, f._notReady.getDocumentCount());
f.startMaintenance();
- ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC));
+ ASSERT_TRUE(f._executor.waitIdle(TIMEOUT));
EXPECT_EQUAL(5u, f._ready.getNumUsedLids());
EXPECT_EQUAL(5u, f._ready.getDocumentCount());
EXPECT_EQUAL(5u, f._notReady.getNumUsedLids());
@@ -1084,7 +1083,7 @@ TEST_F("require that active bucket is not moved until de-activated", Maintenance
// de-activate bucket 1
f._ready.setBucketState(readyDocs.getBucket(1), false);
f.notifyBucketStateChanged(readyDocs.getBucket(1), BucketInfo::NOT_ACTIVE);
- ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC));
+ ASSERT_TRUE(f._executor.waitIdle(TIMEOUT));
EXPECT_EQUAL(2u, f._ready.getNumUsedLids());
EXPECT_EQUAL(2u, f._ready.getDocumentCount());
EXPECT_EQUAL(8u, f._notReady.getNumUsedLids());
@@ -1093,7 +1092,7 @@ TEST_F("require that active bucket is not moved until de-activated", Maintenance
// re-activate bucket 1
f._ready.setBucketState(readyDocs.getBucket(1), true);
f.notifyBucketStateChanged(readyDocs.getBucket(1), BucketInfo::ACTIVE);
- ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC));
+ ASSERT_TRUE(f._executor.waitIdle(TIMEOUT));
EXPECT_EQUAL(5u, f._ready.getNumUsedLids());
EXPECT_EQUAL(5u, f._ready.getDocumentCount());
EXPECT_EQUAL(5u, f._notReady.getNumUsedLids());
@@ -1102,7 +1101,7 @@ TEST_F("require that active bucket is not moved until de-activated", Maintenance
// de-activate bucket 1
f._ready.setBucketState(readyDocs.getBucket(1), false);
f.notifyBucketStateChanged(readyDocs.getBucket(1), BucketInfo::NOT_ACTIVE);
- ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC));
+ ASSERT_TRUE(f._executor.waitIdle(TIMEOUT));
EXPECT_EQUAL(2u, f._ready.getNumUsedLids());
EXPECT_EQUAL(2u, f._ready.getDocumentCount());
EXPECT_EQUAL(8u, f._notReady.getNumUsedLids());
@@ -1111,7 +1110,7 @@ TEST_F("require that active bucket is not moved until de-activated", Maintenance
// re-activate bucket 1
f._ready.setBucketState(readyDocs.getBucket(1), true);
f.notifyBucketStateChanged(readyDocs.getBucket(1), BucketInfo::ACTIVE);
- ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC));
+ ASSERT_TRUE(f._executor.waitIdle(TIMEOUT));
EXPECT_EQUAL(5u, f._ready.getNumUsedLids());
EXPECT_EQUAL(5u, f._ready.getDocumentCount());
EXPECT_EQUAL(5u, f._notReady.getNumUsedLids());
@@ -1125,19 +1124,19 @@ TEST_F("require that a simple maintenance job is executed", MaintenanceControlle
f._mc.registerJobInMasterThread(std::move(job));
f._injectDefaultJobs = false;
f.startMaintenance();
- bool done = myJob._latch.await(TIMEOUT_MS);
+ bool done = myJob._latch.await(TIMEOUT);
EXPECT_TRUE(done);
EXPECT_EQUAL(0u, myJob._latch.getCount());
}
TEST_F("require that a split maintenance job is executed", MaintenanceControllerFixture)
{
- auto job = std::make_unique<MySplitJob>(200ms, TIMEOUT_SEC * 2, 3);
+ auto job = std::make_unique<MySplitJob>(200ms, TIMEOUT * 2, 3);
MySplitJob &myJob = *job;
f._mc.registerJobInMasterThread(std::move(job));
f._injectDefaultJobs = false;
f.startMaintenance();
- bool done = myJob._latch.await(TIMEOUT_MS);
+ bool done = myJob._latch.await(TIMEOUT);
EXPECT_TRUE(done);
EXPECT_EQUAL(0u, myJob._latch.getCount());
}
@@ -1145,9 +1144,9 @@ TEST_F("require that a split maintenance job is executed", MaintenanceController
TEST_F("require that a blocked job is unblocked and executed after thaw bucket",
MaintenanceControllerFixture)
{
- auto job1 = std::make_unique<MySimpleJob>(TIMEOUT_SEC * 2, TIMEOUT_SEC * 2, 1);
+ auto job1 = std::make_unique<MySimpleJob>(TIMEOUT * 2, TIMEOUT * 2, 1);
MySimpleJob &myJob1 = *job1;
- auto job2 = std::make_unique< MySimpleJob>(TIMEOUT_SEC * 2, TIMEOUT_SEC * 2, 0);
+ auto job2 = std::make_unique< MySimpleJob>(TIMEOUT * 2, TIMEOUT * 2, 0);
MySimpleJob &myJob2 = *job2;
f._mc.registerJobInMasterThread(std::move(job1));
f._mc.registerJobInMasterThread(std::move(job2));
@@ -1169,7 +1168,7 @@ TEST_F("require that a blocked job is unblocked and executed after thaw bucket",
f._executor.sync();
EXPECT_FALSE(myJob1.isBlocked());
EXPECT_FALSE(myJob2.isBlocked());
- bool done1 = myJob1._latch.await(TIMEOUT_MS);
+ bool done1 = myJob1._latch.await(TIMEOUT);
EXPECT_TRUE(done1);
std::this_thread::sleep_for(2s);
EXPECT_EQUAL(0u, myJob2._runCnt);
@@ -1190,14 +1189,14 @@ TEST_F("require that blocked jobs are not executed", MaintenanceControllerFixtur
TEST_F("require that maintenance controller state list jobs", MaintenanceControllerFixture)
{
{
- IMaintenanceJob::UP job1(new MySimpleJob(TIMEOUT_SEC * 2, TIMEOUT_SEC * 2, 0));
- IMaintenanceJob::UP job2(new MyLongRunningJob(200ms, 200ms));
+ auto job1 = std::make_unique<MySimpleJob>(TIMEOUT * 2, TIMEOUT * 2, 0);
+ auto job2 = std::make_unique<MyLongRunningJob>(200ms, 200ms);
auto &longRunningJob = dynamic_cast<MyLongRunningJob &>(*job2);
f._mc.registerJobInMasterThread(std::move(job1));
f._mc.registerJobInMasterThread(std::move(job2));
f._injectDefaultJobs = false;
f.startMaintenance();
- longRunningJob._firstRun.await(TIMEOUT_MS);
+ longRunningJob._firstRun.await(TIMEOUT);
}
MaintenanceControllerExplorer explorer(f._mc.getJobList());
diff --git a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp
index fae2e9f2d52..b1c188b2f9f 100644
--- a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp
+++ b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp
@@ -14,7 +14,7 @@
#include <vespa/vespalib/test/insertion_operators.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <mutex>
-#include <chrono>
+#include <thread>
#include <vespa/log/log.h>
LOG_SETUP("flushengine_test");
@@ -31,8 +31,8 @@ using searchcorespi::IFlushTarget;
using searchcorespi::FlushTask;
using vespalib::Slime;
-constexpr long LONG_TIMEOUT = 66666;
-constexpr long SHORT_TIMEOUT = 1;
+constexpr vespalib::duration LONG_TIMEOUT = 66666ms;
+constexpr vespalib::duration SHORT_TIMEOUT = 1ms;
constexpr vespalib::duration IINTERVAL = 1s;
class SimpleExecutor : public vespalib::Executor {
diff --git a/searchcore/src/tests/proton/matching/docid_range_scheduler/docid_range_scheduler_test.cpp b/searchcore/src/tests/proton/matching/docid_range_scheduler/docid_range_scheduler_test.cpp
index 4814ab4cb49..510269f2195 100644
--- a/searchcore/src/tests/proton/matching/docid_range_scheduler/docid_range_scheduler_test.cpp
+++ b/searchcore/src/tests/proton/matching/docid_range_scheduler/docid_range_scheduler_test.cpp
@@ -1,9 +1,8 @@
// 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/searchcore/proton/matching/docid_range_scheduler.h>
-#include <chrono>
-#include <thread>
using namespace proton::matching;
using vespalib::TimeBomb;
diff --git a/searchcore/src/tests/proton/metrics/documentdb_job_trackers/documentdb_job_trackers_test.cpp b/searchcore/src/tests/proton/metrics/documentdb_job_trackers/documentdb_job_trackers_test.cpp
index c108e98cc2a..1b9c60b379e 100644
--- a/searchcore/src/tests/proton/metrics/documentdb_job_trackers/documentdb_job_trackers_test.cpp
+++ b/searchcore/src/tests/proton/metrics/documentdb_job_trackers/documentdb_job_trackers_test.cpp
@@ -4,6 +4,7 @@
#include <vespa/searchcore/proton/metrics/job_tracked_flush_target.h>
#include <vespa/searchcore/proton/test/dummy_flush_target.h>
#include <vespa/vespalib/testkit/testapp.h>
+#include <thread>
#include <vespa/log/log.h>
LOG_SETUP("documentdb_job_trackers_test");
diff --git a/searchcore/src/tests/proton/metrics/job_tracked_flush/job_tracked_flush_test.cpp b/searchcore/src/tests/proton/metrics/job_tracked_flush/job_tracked_flush_test.cpp
index 7c22aab2285..20d75972c8b 100644
--- a/searchcore/src/tests/proton/metrics/job_tracked_flush/job_tracked_flush_test.cpp
+++ b/searchcore/src/tests/proton/metrics/job_tracked_flush/job_tracked_flush_test.cpp
@@ -27,8 +27,8 @@ struct MyFlushTask : public searchcorespi::FlushTask
MyFlushTask(Gate &execGate) : _execGate(execGate) {}
// Implements searchcorespi::FlushTask
- virtual void run() override {
- _execGate.await(5000);
+ void run() override {
+ _execGate.await(5s);
}
virtual search::SerialNum getFlushSerial() const override { return 5; }
};
@@ -39,7 +39,7 @@ struct MyFlushTarget : public test::DummyFlushTarget
SerialNum _initFlushSerial;
Gate _execGate;
Gate _initGate;
- MyFlushTarget()
+ MyFlushTarget() noexcept
: test::DummyFlushTarget("mytarget", Type::FLUSH, Component::OTHER),
_initFlushSerial(0),
_execGate(),
@@ -50,8 +50,8 @@ struct MyFlushTarget : public test::DummyFlushTarget
FlushTask::UP initFlush(SerialNum currentSerial, std::shared_ptr<search::IFlushToken>) override {
if (currentSerial > 0) {
_initFlushSerial = currentSerial;
- _initGate.await(5000);
- return FlushTask::UP(new MyFlushTask(_execGate));
+ _initGate.await(5s);
+ return std::make_unique<MyFlushTask>(_execGate);
}
return FlushTask::UP();
}
@@ -66,8 +66,8 @@ struct Fixture
Gate _taskGate;
ThreadStackExecutor _exec;
Fixture(uint32_t numJobTrackings = 1)
- : _tracker(new SimpleJobTracker(numJobTrackings)),
- _target(new MyFlushTarget()),
+ : _tracker(std::make_shared<SimpleJobTracker>(numJobTrackings)),
+ _target(std::make_shared<MyFlushTarget>()),
_trackedFlush(_tracker, _target),
_task(),
_taskGate(),
@@ -95,12 +95,12 @@ TEST_F("require that flush task init is tracked", Fixture)
EXPECT_EQUAL(1u, f._tracker->_ended.getCount());
f._exec.execute(makeLambdaTask([&]() {f.initFlush(FLUSH_SERIAL); }));
- f._tracker->_started.await(5000);
+ f._tracker->_started.await(5s);
EXPECT_EQUAL(0u, f._tracker->_started.getCount());
EXPECT_EQUAL(1u, f._tracker->_ended.getCount());
f._target->_initGate.countDown();
- f._taskGate.await(5000);
+ f._taskGate.await(5s);
EXPECT_EQUAL(0u, f._tracker->_ended.getCount());
{
JobTrackedFlushTask *trackedTask = dynamic_cast<JobTrackedFlushTask *>(f._task.get());
@@ -114,18 +114,18 @@ TEST_F("require that flush task execution is tracked", Fixture(2))
{
f._exec.execute(makeLambdaTask([&]() { f.initFlush(FLUSH_SERIAL); }));
f._target->_initGate.countDown();
- f._taskGate.await(5000);
+ f._taskGate.await(5s);
EXPECT_EQUAL(1u, f._tracker->_started.getCount());
EXPECT_EQUAL(1u, f._tracker->_ended.getCount());
f._exec.execute(std::move(f._task));
- f._tracker->_started.await(5000);
+ f._tracker->_started.await(5s);
EXPECT_EQUAL(0u, f._tracker->_started.getCount());
EXPECT_EQUAL(1u, f._tracker->_ended.getCount());
f._target->_execGate.countDown();
- f._tracker->_ended.await(5000);
+ f._tracker->_ended.await(5s);
EXPECT_EQUAL(0u, f._tracker->_ended.getCount());
}
diff --git a/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp b/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp
index f028de23be6..63c861a60d9 100644
--- a/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp
+++ b/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp
@@ -7,6 +7,7 @@
#include <vespa/searchcore/proton/reference/gid_to_lid_change_listener.h>
#include <vespa/searchlib/common/i_gid_to_lid_mapper_factory.h>
#include <vespa/vespalib/util/destructor_callbacks.h>
+#include <vespa/vespalib/util/gate.h>
#include <vespa/searchlib/test/mock_gid_to_lid_mapping.h>
#include <map>
#include <vespa/log/log.h>
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp
index 368e4ce12f2..372bfe5d631 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp
@@ -199,7 +199,7 @@ AttributeInitializer::loadAttribute(const AttributeVectorSP &attr,
return false;
} else {
attr->commit(serialNum, serialNum);
- EventLogger::loadAttributeComplete(_documentSubDbName, attr->getName(), vespalib::count_ms(timer.elapsed()));
+ EventLogger::loadAttributeComplete(_documentSubDbName, attr->getName(), timer.elapsed());
}
return true;
}
diff --git a/searchcore/src/vespa/searchcore/proton/common/eventlogger.cpp b/searchcore/src/vespa/searchcore/proton/common/eventlogger.cpp
index 5966589d635..20b87f4bc63 100644
--- a/searchcore/src/vespa/searchcore/proton/common/eventlogger.cpp
+++ b/searchcore/src/vespa/searchcore/proton/common/eventlogger.cpp
@@ -10,6 +10,7 @@ LOG_SETUP(".proton.common.eventlogger");
using search::util::LogUtil;
using vespalib::JSONStringer;
using vespalib::make_string;
+using vespalib::count_ms;
namespace {
@@ -32,12 +33,12 @@ doTransactionLogReplayStart(const string &domainName, SerialNum first, SerialNum
}
void
-doTransactionLogReplayComplete(const string &domainName, int64_t elapsedTimeMs, const string &eventName)
+doTransactionLogReplayComplete(const string &domainName, vespalib::duration elapsedTime, const string &eventName)
{
JSONStringer jstr;
jstr.beginObject();
jstr.appendKey("domain").appendString(domainName);
- jstr.appendKey("time.elapsed.ms").appendInt64(elapsedTimeMs);
+ jstr.appendKey("time.elapsed.ms").appendInt64(count_ms(elapsedTime));
jstr.endObject();
EV_STATE(eventName.c_str(), jstr.toString().data());
}
@@ -71,9 +72,9 @@ EventLogger::transactionLogReplayProgress(const string &domainName, float progre
}
void
-EventLogger::transactionLogReplayComplete(const string &domainName, int64_t elapsedTimeMs)
+EventLogger::transactionLogReplayComplete(const string &domainName, vespalib::duration elapsedTime)
{
- doTransactionLogReplayComplete(domainName, elapsedTimeMs, "transactionlog.replay.complete");
+ doTransactionLogReplayComplete(domainName, elapsedTime, "transactionlog.replay.complete");
}
void
@@ -109,13 +110,13 @@ EventLogger::flushStart(const string &name, int64_t beforeMemory, int64_t afterM
}
void
-EventLogger::flushComplete(const string &name, int64_t elapsedTimeMs, SerialNum flushed,
+EventLogger::flushComplete(const string &name, vespalib::duration elapsedTime, SerialNum flushed,
const string &outputPath, size_t outputPathElems)
{
JSONStringer jstr;
jstr.beginObject();
jstr.appendKey("name").appendString(name);
- jstr.appendKey("time.elapsed.ms").appendInt64(elapsedTimeMs);
+ jstr.appendKey("time.elapsed.ms").appendInt64(count_ms(elapsedTime));
jstr.appendKey("serialnum")
.beginObject()
.appendKey("flushed").appendInt64(flushed)
@@ -237,13 +238,13 @@ EventLogger::reprocessDocumentsProgress(const string &subDb, double progress, do
void
-EventLogger::reprocessDocumentsComplete(const string &subDb, double visitCost, int64_t elapsedTimeMs)
+EventLogger::reprocessDocumentsComplete(const string &subDb, double visitCost, vespalib::duration elapsedTime)
{
JSONStringer jstr;
jstr.beginObject();
jstr.appendKey("documentsubdb").appendString(subDb);
jstr.appendKey("visitcost").appendDouble(visitCost);
- jstr.appendKey("time.elapsed.ms").appendInt64(elapsedTimeMs);
+ jstr.appendKey("time.elapsed.ms").appendInt64(count_ms(elapsedTime));
jstr.endObject();
EV_STATE("reprocess.documents.complete", jstr.toString().data());
}
@@ -261,13 +262,13 @@ EventLogger::loadAttributeStart(const vespalib::string &subDbName, const vespali
void
EventLogger::loadAttributeComplete(const vespalib::string &subDbName,
- const vespalib::string &attrName, int64_t elapsedTimeMs)
+ const vespalib::string &attrName, vespalib::duration elapsedTime)
{
JSONStringer jstr;
jstr.beginObject();
jstr.appendKey("documentsubdb").appendString(subDbName);
jstr.appendKey("name").appendString(attrName);
- jstr.appendKey("time.elapsed.ms").appendInt64(elapsedTimeMs);
+ jstr.appendKey("time.elapsed.ms").appendInt64(count_ms(elapsedTime));
jstr.endObject();
EV_STATE("load.attribute.complete", jstr.toString().data());
}
@@ -285,12 +286,12 @@ loadComponentStart(const vespalib::string &subDbName, const vespalib::string &co
}
void
-loadComponentComplete(const vespalib::string &subDbName, const vespalib::string &componentName, int64_t elapsedTimeMs)
+loadComponentComplete(const vespalib::string &subDbName, const vespalib::string &componentName, vespalib::duration elapsedTime)
{
JSONStringer jstr;
jstr.beginObject();
jstr.appendKey("documentsubdb").appendString(subDbName);
- jstr.appendKey("time.elapsed.ms").appendInt64(elapsedTimeMs);
+ jstr.appendKey("time.elapsed.ms").appendInt64(count_ms(elapsedTime));
jstr.endObject();
EV_STATE(make_string("load.%s.complete", componentName.c_str()).c_str(), jstr.toString().data());
}
@@ -304,9 +305,9 @@ EventLogger::loadDocumentMetaStoreStart(const vespalib::string &subDbName)
}
void
-EventLogger::loadDocumentMetaStoreComplete(const vespalib::string &subDbName, int64_t elapsedTimeMs)
+EventLogger::loadDocumentMetaStoreComplete(const vespalib::string &subDbName, vespalib::duration elapsedTime)
{
- loadComponentComplete(subDbName, "documentmetastore", elapsedTimeMs);
+ loadComponentComplete(subDbName, "documentmetastore", elapsedTime);
}
void
@@ -316,9 +317,9 @@ EventLogger::loadDocumentStoreStart(const vespalib::string &subDbName)
}
void
-EventLogger::loadDocumentStoreComplete(const vespalib::string &subDbName, int64_t elapsedTimeMs)
+EventLogger::loadDocumentStoreComplete(const vespalib::string &subDbName, vespalib::duration elapsedTime)
{
- loadComponentComplete(subDbName, "documentstore", elapsedTimeMs);
+ loadComponentComplete(subDbName, "documentstore", elapsedTime);
}
void
diff --git a/searchcore/src/vespa/searchcore/proton/common/eventlogger.h b/searchcore/src/vespa/searchcore/proton/common/eventlogger.h
index 574e650732a..7d32c777f98 100644
--- a/searchcore/src/vespa/searchcore/proton/common/eventlogger.h
+++ b/searchcore/src/vespa/searchcore/proton/common/eventlogger.h
@@ -3,6 +3,7 @@
#include <vespa/searchlib/common/serialnum.h>
#include <vespa/vespalib/stllike/string.h>
+#include <vespa/vespalib/util/time.h>
#include <vector>
namespace proton {
@@ -15,7 +16,7 @@ private:
typedef search::SerialNum SerialNum;
typedef vespalib::string string;
public:
- static void transactionLogReplayComplete(const string &domainName, int64_t elapsedTimeMs);
+ static void transactionLogReplayComplete(const string &domainName, vespalib::duration elapsedTime);
static void populateAttributeStart(const std::vector<string> &names);
static void populateAttributeComplete(const std::vector<string> &names, int64_t documentsVisisted);
static void populateDocumentFieldStart(const string &fieldName);
@@ -23,7 +24,7 @@ public:
static void lidSpaceCompactionComplete(const string &subDbName, uint32_t lidLimit);
static void reprocessDocumentsStart(const string &subDb, double visitCost);
static void reprocessDocumentsProgress(const string &subDb, double progress, double visitCost);
- static void reprocessDocumentsComplete(const string &subDb, double visitCost, int64_t elapsedTimeMs);
+ static void reprocessDocumentsComplete(const string &subDb, double visitCost, vespalib::duration elapsedTime);
static void transactionLogReplayStart(const string &domainName,
SerialNum first,
SerialNum last);
@@ -40,18 +41,18 @@ public:
SerialNum unflushed,
SerialNum current);
static void flushComplete(const string &name,
- int64_t elapsedTimeMs,
+ vespalib::duration elapsedTime,
SerialNum flushed,
const string &outputPath,
size_t outputPathElems);
static void flushPrune(const string &name, SerialNum oldestFlushed);
static void loadAttributeStart(const vespalib::string &subDbName, const vespalib::string &attrName);
static void loadAttributeComplete(const vespalib::string &subDbName,
- const vespalib::string &attrName, int64_t elapsedTimeMs);
+ const vespalib::string &attrName, vespalib::duration elapsedTime);
static void loadDocumentMetaStoreStart(const vespalib::string &subDbName);
- static void loadDocumentMetaStoreComplete(const vespalib::string &subDbName, int64_t elapsedTimeMs);
+ static void loadDocumentMetaStoreComplete(const vespalib::string &subDbName, vespalib::duration elapsedTime);
static void loadDocumentStoreStart(const vespalib::string &subDbName);
- static void loadDocumentStoreComplete(const vespalib::string &subDbName, int64_t elapsedTimeMs);
+ static void loadDocumentStoreComplete(const vespalib::string &subDbName, vespalib::duration elapsedTime);
static void transactionLogPruneComplete(const string &domainName, SerialNum prunedSerial);
};
diff --git a/searchcore/src/vespa/searchcore/proton/docsummary/summarymanagerinitializer.cpp b/searchcore/src/vespa/searchcore/proton/docsummary/summarymanagerinitializer.cpp
index 29346903aef..85c92f0da6b 100644
--- a/searchcore/src/vespa/searchcore/proton/docsummary/summarymanagerinitializer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/docsummary/summarymanagerinitializer.cpp
@@ -43,7 +43,7 @@ SummaryManagerInitializer::run()
*_result = std::make_shared<SummaryManager>
(_summaryExecutor, _storeCfg, _grow, _baseDir, _docTypeName,
_tuneFile, _fileHeaderContext, _tlSyncer, _bucketizer);
- EventLogger::loadDocumentStoreComplete(_subDbName, vespalib::count_ms(timer.elapsed()));
+ EventLogger::loadDocumentStoreComplete(_subDbName, timer.elapsed());
}
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp
index a1a8297d5c0..2bf6a1c8432 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp
@@ -51,7 +51,7 @@ DocumentMetaStoreInitializer::run()
} else {
_dms->commit(snap.syncToken, snap.syncToken);
}
- EventLogger::loadDocumentMetaStoreComplete(_subDbName, vespalib::count_ms(stopWatch.elapsed()));
+ EventLogger::loadDocumentMetaStoreComplete(_subDbName, stopWatch.elapsed());
}
} else {
vespalib::mkdir(_baseDir, false);
diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp
index 29fa2c95945..50162936835 100644
--- a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp
+++ b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp
@@ -372,7 +372,7 @@ FlushEngine::flushDone(const FlushContext &ctx, uint32_t taskId)
}
if (LOG_WOULD_LOG(event)) {
FlushStats stats = ctx.getTarget()->getLastFlushStats();
- EventLogger::flushComplete(ctx.getName(), vespalib::count_ms(duration), ctx.getTarget()->getFlushedSerialNum(),
+ EventLogger::flushComplete(ctx.getName(), duration, ctx.getTarget()->getFlushedSerialNum(),
stats.getPath(), stats.getPathElementsToLog());
}
LOG(debug, "FlushEngine::flushDone(taskId='%d') took '%f' secs", taskId, vespalib::to_s(duration));
diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
index e4f3cc8edc2..b3376ece351 100644
--- a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
+++ b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
@@ -102,7 +102,7 @@ public:
* @param idleInterval The interval between when flushes are checked whne there are no one progressing.
*/
FlushEngine(std::shared_ptr<flushengine::ITlsStatsFactory> tlsStatsFactory,
- IFlushStrategy::SP strategy, uint32_t numThreads, vespalib::duration idleIntervalMS);
+ IFlushStrategy::SP strategy, uint32_t numThreads, vespalib::duration idleInterval);
/**
* Destructor. Waits for all pending tasks to complete.
diff --git a/searchcore/src/vespa/searchcore/proton/reprocessing/reprocess_documents_task.cpp b/searchcore/src/vespa/searchcore/proton/reprocessing/reprocess_documents_task.cpp
index d8e0fcc7843..d5cbb4615f4 100644
--- a/searchcore/src/vespa/searchcore/proton/reprocessing/reprocess_documents_task.cpp
+++ b/searchcore/src/vespa/searchcore/proton/reprocessing/reprocess_documents_task.cpp
@@ -44,8 +44,7 @@ ReprocessDocumentsTask::run()
docstore.accept(_handler, *this, *_docTypeRepo);
}
_handler.done();
- EventLogger::reprocessDocumentsComplete(_subDbName, _visitorCost,
- duration_cast<milliseconds>(clock::now() - _start).count());
+ EventLogger::reprocessDocumentsComplete(_subDbName, _visitorCost,(clock::now() - _start));
}
}
@@ -55,8 +54,8 @@ ReprocessDocumentsTask::updateProgress(double progress)
_visitorProgress = progress;
double deltaProgress = progress - _loggedProgress;
if (deltaProgress >= 0.01) {
- auto secondsSinceLastLog = duration_cast<seconds>(clock::now() - _lastLogTime);
- if (secondsSinceLastLog >= 60s || deltaProgress >= 0.10) {
+ auto timeSinceLastLog = clock::now() - _lastLogTime;
+ if (timeSinceLastLog >= 60s || deltaProgress >= 0.10) {
EventLogger::reprocessDocumentsProgress(_subDbName, progress, _visitorCost);
_lastLogTime = clock::now();
_loggedProgress = progress;
diff --git a/searchcore/src/vespa/searchcore/proton/server/transactionlogmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/transactionlogmanager.cpp
index 9c928f49ca8..b776e32e0db 100644
--- a/searchcore/src/vespa/searchcore/proton/server/transactionlogmanager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/transactionlogmanager.cpp
@@ -20,7 +20,7 @@ void
TransactionLogManager::doLogReplayComplete(const vespalib::string &domainName,
vespalib::duration elapsedTime) const
{
- EventLogger::transactionLogReplayComplete(domainName, vespalib::count_ms(elapsedTime));
+ EventLogger::transactionLogReplayComplete(domainName, elapsedTime);
}
diff --git a/searchcore/src/vespa/searchcore/proton/test/simple_job_tracker.h b/searchcore/src/vespa/searchcore/proton/test/simple_job_tracker.h
index cf4decf0f4a..9048fb7a356 100644
--- a/searchcore/src/vespa/searchcore/proton/test/simple_job_tracker.h
+++ b/searchcore/src/vespa/searchcore/proton/test/simple_job_tracker.h
@@ -11,7 +11,7 @@ struct SimpleJobTracker : public IJobTracker
typedef std::shared_ptr<SimpleJobTracker> SP;
vespalib::CountDownLatch _started;
vespalib::CountDownLatch _ended;
- SimpleJobTracker(uint32_t numJobTrackings)
+ SimpleJobTracker(uint32_t numJobTrackings) noexcept
: _started(numJobTrackings),
_ended(numJobTrackings)
{}
diff --git a/searchlib/src/tests/transactionlog/translogclient_test.cpp b/searchlib/src/tests/transactionlog/translogclient_test.cpp
index e097eebd42c..fd598eb2d31 100644
--- a/searchlib/src/tests/transactionlog/translogclient_test.cpp
+++ b/searchlib/src/tests/transactionlog/translogclient_test.cpp
@@ -6,6 +6,7 @@
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/document/util/bytebuffer.h>
#include <vespa/fastos/file.h>
+#include <thread>
#include <vespa/log/log.h>
LOG_SETUP("translogclient_test");
diff --git a/slobrok/src/tests/configure/configure.cpp b/slobrok/src/tests/configure/configure.cpp
index 0e5b68053c8..98c716b3a48 100644
--- a/slobrok/src/tests/configure/configure.cpp
+++ b/slobrok/src/tests/configure/configure.cpp
@@ -12,6 +12,7 @@
#include <vespa/vespalib/util/host_name.h>
#include <algorithm>
#include <iostream>
+#include <thread>
#include <vespa/log/log.h>
LOG_SETUP("configure_test");
diff --git a/slobrok/src/tests/mirrorapi/mirrorapi.cpp b/slobrok/src/tests/mirrorapi/mirrorapi.cpp
index 4126f34716f..ae309f8c661 100644
--- a/slobrok/src/tests/mirrorapi/mirrorapi.cpp
+++ b/slobrok/src/tests/mirrorapi/mirrorapi.cpp
@@ -8,6 +8,7 @@
#include <vespa/fnet/frt/supervisor.h>
#include <vespa/fnet/frt/target.h>
#include <vespa/fnet/transport.h>
+#include <thread>
#include <vespa/log/log.h>
LOG_SETUP("mirrorapi_test");
diff --git a/slobrok/src/tests/registerapi/registerapi.cpp b/slobrok/src/tests/registerapi/registerapi.cpp
index 92f08ee41cb..59bc4690985 100644
--- a/slobrok/src/tests/registerapi/registerapi.cpp
+++ b/slobrok/src/tests/registerapi/registerapi.cpp
@@ -8,6 +8,7 @@
#include <vespa/fnet/frt/supervisor.h>
#include <sstream>
#include <algorithm>
+#include <thread>
#include <vespa/log/log.h>
LOG_SETUP("registerapi_test");
diff --git a/slobrok/src/tests/standalone/standalone.cpp b/slobrok/src/tests/standalone/standalone.cpp
index 65553c57530..883aeed1494 100644
--- a/slobrok/src/tests/standalone/standalone.cpp
+++ b/slobrok/src/tests/standalone/standalone.cpp
@@ -3,6 +3,7 @@
#include <vespa/slobrok/server/slobrokserver.h>
#include <vespa/fnet/frt/supervisor.h>
#include <vespa/fnet/frt/target.h>
+#include <thread>
//-----------------------------------------------------------------------------
diff --git a/staging_vespalib/src/tests/clock/clock_test.cpp b/staging_vespalib/src/tests/clock/clock_test.cpp
index 06eee21d2b9..b1572d11dd7 100644
--- a/staging_vespalib/src/tests/clock/clock_test.cpp
+++ b/staging_vespalib/src/tests/clock/clock_test.cpp
@@ -3,6 +3,7 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/clock.h>
#include <vespa/fastos/thread.h>
+#include <thread>
using vespalib::Clock;
using vespalib::duration;
diff --git a/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp b/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
index 04a811494c9..24607add153 100644
--- a/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
+++ b/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/shutdownguard.h>
+#include <thread>
#include <unistd.h>
#include <sys/wait.h>
#include <cstdlib>
diff --git a/staging_vespalib/src/tests/timer/timer_test.cpp b/staging_vespalib/src/tests/timer/timer_test.cpp
index 04b541e75e9..2031e3cdcbe 100644
--- a/staging_vespalib/src/tests/timer/timer_test.cpp
+++ b/staging_vespalib/src/tests/timer/timer_test.cpp
@@ -37,10 +37,10 @@ void Test::testScheduling()
vespalib::CountDownLatch latch1(3);
vespalib::CountDownLatch latch2(2);
ScheduledExecutor timer;
- timer.scheduleAtFixedRate(Task::UP(new TestTask(latch1)), 100ms, 200ms);
- timer.scheduleAtFixedRate(Task::UP(new TestTask(latch2)), 500ms, 500ms);
- EXPECT_TRUE(latch1.await(60000));
- EXPECT_TRUE(latch2.await(60000));
+ timer.scheduleAtFixedRate(std::make_unique<TestTask>(latch1), 100ms, 200ms);
+ timer.scheduleAtFixedRate(std::make_unique<TestTask>(latch2), 500ms, 500ms);
+ EXPECT_TRUE(latch1.await(60s));
+ EXPECT_TRUE(latch2.await(60s));
}
void Test::testReset()
@@ -49,9 +49,9 @@ void Test::testReset()
ScheduledExecutor timer;
timer.scheduleAtFixedRate(std::make_unique<TestTask>(latch1), 2s, 3s);
timer.reset();
- EXPECT_TRUE(!latch1.await(3000));
+ EXPECT_TRUE(!latch1.await(3s));
timer.scheduleAtFixedRate(std::make_unique<TestTask>(latch1), 200ms, 300ms);
- EXPECT_TRUE(latch1.await(60000));
+ EXPECT_TRUE(latch1.await(60s));
}
TEST_APPHOOK(Test)
diff --git a/staging_vespalib/src/vespa/vespalib/util/adaptive_sequenced_executor.h b/staging_vespalib/src/vespa/vespalib/util/adaptive_sequenced_executor.h
index ed2209d130a..4e0388caf8a 100644
--- a/staging_vespalib/src/vespa/vespalib/util/adaptive_sequenced_executor.h
+++ b/staging_vespalib/src/vespa/vespalib/util/adaptive_sequenced_executor.h
@@ -6,7 +6,6 @@
#include <vespa/vespalib/util/arrayqueue.hpp>
#include <vespa/vespalib/util/gate.h>
#include <vespa/vespalib/util/eventbarrier.hpp>
-#include <vespa/vespalib/util/gate.h>
#include <vespa/fastos/thread.h>
#include <mutex>
#include <condition_variable>
diff --git a/vbench/src/apps/vbench/vbench.cpp b/vbench/src/apps/vbench/vbench.cpp
index ab695f0b728..4b3419b2f50 100644
--- a/vbench/src/apps/vbench/vbench.cpp
+++ b/vbench/src/apps/vbench/vbench.cpp
@@ -45,8 +45,8 @@ int run(const std::string &cfg_name) {
vespalib::RunnablePair runBoth(vbench, notify);
vespalib::Thread thread(runBoth);
thread.start();
- while (!SIG::INT.check() && !SIG::TERM.check() && !done.await(1000)) {}
- if (!done.await(0)) {
+ while (!SIG::INT.check() && !SIG::TERM.check() && !done.await(1s)) {}
+ if (!done.await(vespalib::duration::zero())) {
vbench.abort();
done.await();
}
diff --git a/vbench/src/tests/time_queue/time_queue_test.cpp b/vbench/src/tests/time_queue/time_queue_test.cpp
index 5ce4feab747..47c1afbfaa9 100644
--- a/vbench/src/tests/time_queue/time_queue_test.cpp
+++ b/vbench/src/tests/time_queue/time_queue_test.cpp
@@ -16,8 +16,8 @@ TEST_MT_FFF("time queue", 2, TimeQueue<int>(10.0, 5.0), vespalib::Gate(), vespal
} else {
double delay;
std::vector<std::unique_ptr<int> > list;
- EXPECT_TRUE(f2.await(20000));
- EXPECT_FALSE(f3.await(20));
+ EXPECT_TRUE(f2.await(20s));
+ EXPECT_FALSE(f3.await(20ms));
{
f1.extract(1.5, list, delay);
ASSERT_EQUAL(1u, list.size());
@@ -38,7 +38,7 @@ TEST_MT_FFF("time queue", 2, TimeQueue<int>(10.0, 5.0), vespalib::Gate(), vespal
EXPECT_EQUAL(0u, list.size());
EXPECT_EQUAL(5.0, delay);
}
- EXPECT_TRUE(f3.await(20000));
+ EXPECT_TRUE(f3.await(20s));
{
f1.extract(99.25, list, delay);
EXPECT_EQUAL(0u, list.size());
diff --git a/vespalib/src/tests/barrier/barrier_test.cpp b/vespalib/src/tests/barrier/barrier_test.cpp
index f829b7fa5d8..2340476d4e0 100644
--- a/vespalib/src/tests/barrier/barrier_test.cpp
+++ b/vespalib/src/tests/barrier/barrier_test.cpp
@@ -13,9 +13,9 @@ struct Fixture {
TEST_MT_F("require that barriers are satisfied by the appropriate number of threads", 3, Fixture(num_threads)) {
if (thread_id == 0) {
f1.latch.countDown();
- EXPECT_FALSE(f.latch.await(250));
+ EXPECT_FALSE(f.latch.await(250ms));
EXPECT_TRUE(f.barrier.await());
- EXPECT_TRUE(f.latch.await(25000));
+ EXPECT_TRUE(f.latch.await(25s));
} else {
EXPECT_TRUE(f1.barrier.await());
f1.latch.countDown();
@@ -27,9 +27,9 @@ TEST_MT_F("require that barriers can be used multiple times", 3, Fixture(num_thr
EXPECT_TRUE(f1.barrier.await());
if (thread_id == 0) {
f1.latch.countDown();
- EXPECT_FALSE(f.latch.await(250));
+ EXPECT_FALSE(f.latch.await(250ms));
EXPECT_TRUE(f.barrier.await());
- EXPECT_TRUE(f.latch.await(25000));
+ EXPECT_TRUE(f.latch.await(25s));
} else {
EXPECT_TRUE(f1.barrier.await());
f1.latch.countDown();
@@ -40,9 +40,9 @@ TEST_MT_F("require that barriers can be broken", 3, Fixture(num_threads)) {
EXPECT_TRUE(f1.barrier.await());
if (thread_id == 0) {
f1.latch.countDown();
- EXPECT_FALSE(f.latch.await(250));
+ EXPECT_FALSE(f.latch.await(250ms));
f1.barrier.destroy();
- EXPECT_TRUE(f.latch.await(25000));
+ EXPECT_TRUE(f.latch.await(25s));
} else {
EXPECT_FALSE(f1.barrier.await());
f1.latch.countDown();
diff --git a/vespalib/src/tests/benchmark_timer/benchmark_timer_test.cpp b/vespalib/src/tests/benchmark_timer/benchmark_timer_test.cpp
index 3f7187458d8..a1781abca81 100644
--- a/vespalib/src/tests/benchmark_timer/benchmark_timer_test.cpp
+++ b/vespalib/src/tests/benchmark_timer/benchmark_timer_test.cpp
@@ -1,6 +1,7 @@
// 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/util/benchmark_timer.h>
+#include <thread>
using namespace vespalib;
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 {
diff --git a/vespalib/src/tests/latch/latch_test.cpp b/vespalib/src/tests/latch/latch_test.cpp
index f29b673e508..a0daf7ef7d5 100644
--- a/vespalib/src/tests/latch/latch_test.cpp
+++ b/vespalib/src/tests/latch/latch_test.cpp
@@ -1,6 +1,7 @@
// Copyright 2018 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/gate.h>
#include <vespa/vespalib/util/latch.h>
@@ -17,9 +18,9 @@ TEST("require that write then read works") {
TEST_MT_FFF("require that read waits for write", 2, Latch<int>(), Gate(), TimeBomb(60)) {
if (thread_id == 0) {
- EXPECT_TRUE(!f2.await(10));
+ EXPECT_TRUE(!f2.await(10ms));
f1.write(123);
- EXPECT_TRUE(f2.await(60000));
+ EXPECT_TRUE(f2.await(60s));
} else {
EXPECT_EQUAL(f1.read(), 123);
f2.countDown();
@@ -32,9 +33,9 @@ TEST_MT_FFF("require that write waits for read", 2, Latch<int>(), Gate(), TimeBo
f1.write(456);
f2.countDown();
} else {
- EXPECT_TRUE(!f2.await(10));
+ EXPECT_TRUE(!f2.await(10ms));
EXPECT_EQUAL(f1.read(), 123);
- EXPECT_TRUE(f2.await(60000));
+ EXPECT_TRUE(f2.await(60s));
EXPECT_EQUAL(f1.read(), 456);
}
}
diff --git a/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp b/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp
index f04fe549c09..8f3cad135ec 100644
--- a/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp
+++ b/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp
@@ -1,6 +1,7 @@
// 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/net/async_resolver.h>
#include <vespa/vespalib/net/socket_spec.h>
#include <atomic>
diff --git a/vespalib/src/tests/net/crypto_socket/crypto_socket_test.cpp b/vespalib/src/tests/net/crypto_socket/crypto_socket_test.cpp
index e938e15f4e6..7230f97818f 100644
--- a/vespalib/src/tests/net/crypto_socket/crypto_socket_test.cpp
+++ b/vespalib/src/tests/net/crypto_socket/crypto_socket_test.cpp
@@ -1,6 +1,7 @@
// Copyright 2018 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/net/crypto_engine.h>
#include <vespa/vespalib/net/tls/tls_crypto_engine.h>
#include <vespa/vespalib/net/tls/maybe_tls_crypto_engine.h>
diff --git a/vespalib/src/tests/net/selector/selector_test.cpp b/vespalib/src/tests/net/selector/selector_test.cpp
index 5c91dfdc122..d13821ce2d0 100644
--- a/vespalib/src/tests/net/selector/selector_test.cpp
+++ b/vespalib/src/tests/net/selector/selector_test.cpp
@@ -1,5 +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/net/socket_address.h>
#include <vespa/vespalib/net/selector.h>
#include <vespa/vespalib/net/socket_utils.h>
diff --git a/vespalib/src/tests/net/send_fd/send_fd_test.cpp b/vespalib/src/tests/net/send_fd/send_fd_test.cpp
index e9921f75207..cc367996bd6 100644
--- a/vespalib/src/tests/net/send_fd/send_fd_test.cpp
+++ b/vespalib/src/tests/net/send_fd/send_fd_test.cpp
@@ -1,5 +1,7 @@
// 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/net/selector.h>
#include <vespa/vespalib/net/socket_spec.h>
#include <vespa/vespalib/net/server_socket.h>
diff --git a/vespalib/src/tests/net/socket/socket_test.cpp b/vespalib/src/tests/net/socket/socket_test.cpp
index 08893c9273b..e3b13b69884 100644
--- a/vespalib/src/tests/net/socket/socket_test.cpp
+++ b/vespalib/src/tests/net/socket/socket_test.cpp
@@ -1,5 +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/net/selector.h>
#include <vespa/vespalib/net/socket_spec.h>
#include <vespa/vespalib/net/server_socket.h>
@@ -9,7 +10,6 @@
#include <vespa/vespalib/test/socket_options_verifier.h>
#include <thread>
#include <functional>
-#include <chrono>
#include <unistd.h>
#include <sys/stat.h>
diff --git a/vespalib/src/tests/net/sync_crypto_socket/sync_crypto_socket_test.cpp b/vespalib/src/tests/net/sync_crypto_socket/sync_crypto_socket_test.cpp
index 56767051dad..8a4961b786b 100644
--- a/vespalib/src/tests/net/sync_crypto_socket/sync_crypto_socket_test.cpp
+++ b/vespalib/src/tests/net/sync_crypto_socket/sync_crypto_socket_test.cpp
@@ -1,6 +1,7 @@
// Copyright 2018 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/net/crypto_engine.h>
#include <vespa/vespalib/net/tls/tls_crypto_engine.h>
#include <vespa/vespalib/net/tls/maybe_tls_crypto_engine.h>
diff --git a/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp b/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp
index 5dc85bc567f..4631f19807e 100644
--- a/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp
+++ b/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp
@@ -7,9 +7,7 @@
#include <vespa/vespalib/net/tls/transport_security_options_reading.h>
#include <vespa/vespalib/net/tls/impl/openssl_tls_context_impl.h>
#include <vespa/vespalib/testkit/test_kit.h>
-
-#include <chrono>
-
+#include <vespa/vespalib/testkit/time_bomb.h>
#include <openssl/ssl.h>
using namespace vespalib;
diff --git a/vespalib/src/tests/portal/handle_manager/handle_manager_test.cpp b/vespalib/src/tests/portal/handle_manager/handle_manager_test.cpp
index 4ce25aa0a7a..844622577e2 100644
--- a/vespalib/src/tests/portal/handle_manager/handle_manager_test.cpp
+++ b/vespalib/src/tests/portal/handle_manager/handle_manager_test.cpp
@@ -1,11 +1,8 @@
// Copyright 2018 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/portal/handle_manager.h>
-#include <vespa/vespalib/util/gate.h>
-
-#include <thread>
-#include <chrono>
#include <atomic>
using namespace vespalib;
@@ -85,9 +82,9 @@ TEST_MT_FF("require that destroy waits for active handle guards", 2, Fixture(),
{
auto guard = f1.manager.lock(f1.handle);
TEST_BARRIER(); // #1
- EXPECT_TRUE(!f1.gate.await(20));
+ EXPECT_TRUE(!f1.gate.await(20ms));
}
- EXPECT_TRUE(f1.gate.await(60000));
+ EXPECT_TRUE(f1.gate.await(60s));
} else {
TEST_BARRIER(); // #1
EXPECT_TRUE(f1.manager.destroy(f1.handle));
diff --git a/vespalib/src/tests/portal/portal_test.cpp b/vespalib/src/tests/portal/portal_test.cpp
index 07d3b9e1bfb..d708f81bdde 100644
--- a/vespalib/src/tests/portal/portal_test.cpp
+++ b/vespalib/src/tests/portal/portal_test.cpp
@@ -1,6 +1,7 @@
// Copyright 2018 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/portal/portal.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/stringfmt.h>
@@ -305,7 +306,7 @@ TEST_MT_FF("require that GET requests can be completed in another thread", 2,
if (thread_id == 0) {
Portal::GetRequest req = f1.latch.read();
f1.exit_callback.countDown();
- std::this_thread::sleep_for(std::chrono::milliseconds(5));
+ std::this_thread::sleep_for(5ms);
req.respond_with_content("text/plain", "hello");
} else {
auto result = fetch(f1.portal->listen_port(), null_crypto(), "/test");
@@ -318,9 +319,9 @@ TEST_MT_FFF("require that bind token destruction waits for active callbacks", 3,
{
if (thread_id == 0) {
Portal::GetRequest req = f1.latch.read();
- EXPECT_TRUE(!f2.await(20));
+ EXPECT_TRUE(!f2.await(20ms));
f1.exit_callback.countDown();
- EXPECT_TRUE(f2.await(60000));
+ EXPECT_TRUE(f2.await(60s));
req.respond_with_content("application/json", "[1,2,3]");
} else if (thread_id == 1) {
f1.enter_callback.await();
@@ -338,9 +339,9 @@ TEST_MT_FFF("require that portal destruction waits for request completion", 3,
if (thread_id == 0) {
Portal::GetRequest req = f1.latch.read();
f1.exit_callback.countDown();
- EXPECT_TRUE(!f2.await(20));
+ EXPECT_TRUE(!f2.await(20ms));
req.respond_with_content("application/json", "[1,2,3]");
- EXPECT_TRUE(f2.await(60000));
+ EXPECT_TRUE(f2.await(60s));
} else if (thread_id == 1) {
f1.enter_callback.await();
f1.bound.reset();
diff --git a/vespalib/src/tests/portal/reactor/reactor_test.cpp b/vespalib/src/tests/portal/reactor/reactor_test.cpp
index b0abc2c9e46..b14bb1dbd3f 100644
--- a/vespalib/src/tests/portal/reactor/reactor_test.cpp
+++ b/vespalib/src/tests/portal/reactor/reactor_test.cpp
@@ -1,14 +1,11 @@
// Copyright 2018 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/net/socket_handle.h>
#include <vespa/vespalib/net/socket_utils.h>
#include <vespa/vespalib/portal/reactor.h>
#include <vespa/vespalib/util/gate.h>
-
-#include <thread>
-#include <chrono>
-
#include <sys/types.h>
#include <sys/socket.h>
#include <fcntl.h>
@@ -150,9 +147,9 @@ TEST_MT_FFFF("require that reactor token destruction waits for io event handling
if (thread_id == 0) {
f2.enter_callback.await();
TEST_BARRIER(); // #1
- EXPECT_TRUE(!f3.await(20));
+ EXPECT_TRUE(!f3.await(20ms));
f2.exit_callback.countDown();
- EXPECT_TRUE(f3.await(60000));
+ EXPECT_TRUE(f3.await(60s));
} else {
TEST_BARRIER(); // #1
f2.token.reset();
diff --git a/vespalib/src/tests/rendezvous/rendezvous_test.cpp b/vespalib/src/tests/rendezvous/rendezvous_test.cpp
index f4ec7870ad5..6a3e87563ed 100644
--- a/vespalib/src/tests/rendezvous/rendezvous_test.cpp
+++ b/vespalib/src/tests/rendezvous/rendezvous_test.cpp
@@ -149,13 +149,13 @@ TEST_MT_FFFF("require that mingle is not called until all threads are present",
for (bool ext_id: {false, true}) {
CountDownLatch &latch = ext_id ? f4 : f2;
if (thread_id == 0) {
- EXPECT_FALSE(latch.await(20));
+ EXPECT_FALSE(latch.await(20ms));
if (ext_id) {
EXPECT_EQUAL(3u, f3.rendezvous(thread_id, thread_id).first);
} else {
EXPECT_EQUAL(3u, f1.rendezvous(thread_id).first);
}
- EXPECT_TRUE(latch.await(25000));
+ EXPECT_TRUE(latch.await(25s));
} else {
if (ext_id) {
EXPECT_EQUAL(3u, f3.rendezvous(thread_id, thread_id).first);
@@ -183,7 +183,7 @@ TEST_MT_FF("require that rendezvous can be run with additional threads", 100, Ad
EXPECT_EQUAL(4950u, f1.rendezvous(res.first).first);
f2.countDown();
}
- EXPECT_TRUE(f2.await(25000));
+ EXPECT_TRUE(f2.await(25s));
}
TEST_MT_FF("require that mingle can modify its own copy of input values", 10, Modify<false>(num_threads), Modify<true>(num_threads)) {
diff --git a/vespalib/src/tests/simple_thread_bundle/simple_thread_bundle_test.cpp b/vespalib/src/tests/simple_thread_bundle/simple_thread_bundle_test.cpp
index d3c562c583c..178a6c49fca 100644
--- a/vespalib/src/tests/simple_thread_bundle/simple_thread_bundle_test.cpp
+++ b/vespalib/src/tests/simple_thread_bundle/simple_thread_bundle_test.cpp
@@ -3,6 +3,7 @@
#include <vespa/vespalib/util/simple_thread_bundle.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/box.h>
+#include <thread>
using namespace vespalib;
using namespace vespalib::fixed_thread_bundle;
@@ -112,9 +113,9 @@ TEST_MT_FFF("require that bundle run waits for all targets", 2, SimpleThreadBund
f2.check(Box<size_t>().add(1).add(1).add(1));
f3.done.countDown();
} else {
- EXPECT_FALSE(f3.done.await(20));
+ EXPECT_FALSE(f3.done.await(20ms));
f3.start.countDown();
- EXPECT_TRUE(f3.done.await(10000));
+ EXPECT_TRUE(f3.done.await(10s));
}
}
diff --git a/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp b/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp
index 71bae66ed2f..f1021ba3b09 100644
--- a/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp
+++ b/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp
@@ -2,6 +2,7 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/simple_thread_bundle.h>
#include <vespa/vespalib/util/box.h>
+#include <thread>
using namespace vespalib;
diff --git a/vespalib/src/tests/sync/sync_test.cpp b/vespalib/src/tests/sync/sync_test.cpp
index 417a9779f9d..e58135d8723 100644
--- a/vespalib/src/tests/sync/sync_test.cpp
+++ b/vespalib/src/tests/sync/sync_test.cpp
@@ -37,12 +37,12 @@ TEST("test gate dropping below zero") {
TEST("test gate non blocking await return correct states") {
Gate gate;
EXPECT_EQUAL(gate.getCount(), 1u);
- EXPECT_EQUAL(gate.await(0), false);
- EXPECT_EQUAL(gate.await(10), false);
+ EXPECT_EQUAL(gate.await(0ms), false);
+ EXPECT_EQUAL(gate.await(10ms), false);
gate.countDown();
EXPECT_EQUAL(gate.getCount(), 0u);
- EXPECT_EQUAL(gate.await(0), true);
- EXPECT_EQUAL(gate.await(10), true);
+ EXPECT_EQUAL(gate.await(0ms), true);
+ EXPECT_EQUAL(gate.await(10ms), true);
}
TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/vespalib/src/tests/testkit-time_bomb/testkit-time_bomb_test.cpp b/vespalib/src/tests/testkit-time_bomb/testkit-time_bomb_test.cpp
index af595db5ae7..5496fedb703 100644
--- a/vespalib/src/tests/testkit-time_bomb/testkit-time_bomb_test.cpp
+++ b/vespalib/src/tests/testkit-time_bomb/testkit-time_bomb_test.cpp
@@ -1,6 +1,7 @@
// 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>
TEST_MT_F("use time bomb in multi-threaded test", 4, vespalib::TimeBomb(60)) {
EXPECT_TRUE(true);
diff --git a/vespalib/src/tests/thread/thread_test.cpp b/vespalib/src/tests/thread/thread_test.cpp
index bcd38190c7e..5820f329b4f 100644
--- a/vespalib/src/tests/thread/thread_test.cpp
+++ b/vespalib/src/tests/thread/thread_test.cpp
@@ -2,6 +2,7 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/thread.h>
+#include <thread>
using namespace vespalib;
diff --git a/vespalib/src/tests/time/time_box_test.cpp b/vespalib/src/tests/time/time_box_test.cpp
index 3c58b929487..32ac68e7254 100644
--- a/vespalib/src/tests/time/time_box_test.cpp
+++ b/vespalib/src/tests/time/time_box_test.cpp
@@ -1,6 +1,7 @@
// 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/time/time_box.h>
+#include <thread>
TEST("require that long-lived timebox returns falling time left numbers") {
vespalib::TimeBox box(3600);
diff --git a/vespalib/src/tests/websocket/websocket_test.cpp b/vespalib/src/tests/websocket/websocket_test.cpp
index db031b247b4..d9cd70c09d1 100644
--- a/vespalib/src/tests/websocket/websocket_test.cpp
+++ b/vespalib/src/tests/websocket/websocket_test.cpp
@@ -5,8 +5,7 @@
#include <vespa/vespalib/websocket/acceptor.h>
#include <vespa/vespalib/websocket/key.h>
#include <vespa/vespalib/websocket/buffer.h>
-#include <thread>
-#include <chrono>
+#include <vespa/vespalib/util/gate.h>
using namespace vespalib;
using namespace vespalib::ws;
@@ -103,7 +102,7 @@ TEST("require that an acceptor can accept connections asynchronously") {
Receptor<Socket> server;
Acceptor acceptor(0, server);
Socket::UP client = SimpleSocket::connect(SocketSpec::from_port(acceptor.port()));
- server.gate.await(60000);
+ server.gate.await(60s);
ASSERT_TRUE(server.obj.get() != nullptr);
ASSERT_TRUE(client.get() != nullptr);
TEST_DO(verify_socket_io_async(*server.obj, *client));
diff --git a/vespalib/src/vespa/vespalib/testkit/test_kit.h b/vespalib/src/vespa/vespalib/testkit/test_kit.h
index 17746c5b0fc..0587396ceda 100644
--- a/vespalib/src/vespa/vespalib/testkit/test_kit.h
+++ b/vespalib/src/vespa/vespalib/testkit/test_kit.h
@@ -9,5 +9,4 @@
#include "test_master.h"
#include "test_hook.h"
#include "test_state_guard.h"
-#include "time_bomb.h"
#include <vespa/vespalib/util/time.h>
diff --git a/vespalib/src/vespa/vespalib/testkit/time_bomb.cpp b/vespalib/src/vespa/vespalib/testkit/time_bomb.cpp
index cbefa285384..2d75fcdd18f 100644
--- a/vespalib/src/vespa/vespalib/testkit/time_bomb.cpp
+++ b/vespalib/src/vespa/vespalib/testkit/time_bomb.cpp
@@ -10,14 +10,14 @@ namespace {
void bomb(Gate &gate, size_t seconds) {
if (seconds > 5) {
- if (gate.await((seconds - 5) * 1000)) {
+ if (gate.await(from_s(seconds - 5))) {
return;
}
}
size_t countdown = std::min(seconds, size_t(5));
while (countdown > 0) {
fprintf(stderr, "...%zu...\n", countdown--);
- if (gate.await(1000)) {
+ if (gate.await(1s)) {
return;
}
}
diff --git a/vespalib/src/vespa/vespalib/util/count_down_latch.h b/vespalib/src/vespa/vespalib/util/count_down_latch.h
index 420be8f7ab2..54b36b414d6 100644
--- a/vespalib/src/vespa/vespalib/util/count_down_latch.h
+++ b/vespalib/src/vespa/vespalib/util/count_down_latch.h
@@ -2,9 +2,9 @@
#pragma once
+#include "time.h"
#include <mutex>
#include <condition_variable>
-#include <chrono>
namespace vespalib {
@@ -71,10 +71,9 @@ public:
* @param maxwait the maximum number of milliseconds to wait
* @return true if the counter reached 0, false if we timed out
**/
- bool await(int maxwait) {
- auto deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(maxwait);
+ bool await(vespalib::duration maxwait) {
std::unique_lock<std::mutex> guard(_lock);
- return _cond.wait_until(guard, deadline, [this]() { return (_count == 0); });
+ return _cond.wait_for(guard, maxwait, [this]() { return (_count == 0); });
}
/**
diff --git a/vespamalloc/src/tests/allocfree/allocfree.cpp b/vespamalloc/src/tests/allocfree/allocfree.cpp
index 86050d4aee9..4f79ba6bccb 100644
--- a/vespamalloc/src/tests/allocfree/allocfree.cpp
+++ b/vespamalloc/src/tests/allocfree/allocfree.cpp
@@ -2,6 +2,7 @@
#include "producerconsumer.h"
#include <vespa/vespalib/testkit/testapp.h>
#include <map>
+#include <thread>
#include <vespa/log/log.h>
LOG_SETUP("allocfree_test");
diff --git a/vespamalloc/src/tests/allocfree/linklist.cpp b/vespamalloc/src/tests/allocfree/linklist.cpp
index 74af380458a..af44ec3430b 100644
--- a/vespamalloc/src/tests/allocfree/linklist.cpp
+++ b/vespamalloc/src/tests/allocfree/linklist.cpp
@@ -3,6 +3,8 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespamalloc/malloc/allocchunk.h>
#include <vespamalloc/util/callstack.h>
+#include <thread>
+
#include <vespa/log/log.h>
LOG_SETUP("linklist_test");