diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-01-05 22:26:40 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-01-05 22:26:40 +0000 |
commit | 83598fd5c744586a34d17a0395619cc6d5080411 (patch) | |
tree | 8bf29261d86fced0b8f2ca8541687d831d645d7c | |
parent | 0e7092d8b7a636ad18e953ae169e3b9f5e4ed421 (diff) |
GC unused code and update includes
35 files changed, 70 insertions, 146 deletions
diff --git a/config/src/tests/configfetcher/configfetcher.cpp b/config/src/tests/configfetcher/configfetcher.cpp index c7a8541e0eb..2a1158de48f 100644 --- a/config/src/tests/configfetcher/configfetcher.cpp +++ b/config/src/tests/configfetcher/configfetcher.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/config/helper/configfetcher.h> #include <vespa/vespalib/util/exception.h> +#include <vespa/fastos/time.h> #include <fstream> #include "config-my.h" #include <atomic> diff --git a/config/src/tests/configholder/configholder.cpp b/config/src/tests/configholder/configholder.cpp index cd799d9bfa0..a9b6dafb72a 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 <vespa/fastos/time.h> using namespace config; diff --git a/config/src/tests/configretriever/configretriever.cpp b/config/src/tests/configretriever/configretriever.cpp index 107c06a9abf..944b0d45da0 100644 --- a/config/src/tests/configretriever/configretriever.cpp +++ b/config/src/tests/configretriever/configretriever.cpp @@ -10,6 +10,7 @@ #include <vespa/config/common/configholder.h> #include <vespa/config/subscription/configsubscription.h> #include <vespa/config/common/exceptions.h> +#include <vespa/fastos/time.h> #include "config-bootstrap.h" #include "config-foo.h" #include "config-bar.h" diff --git a/config/src/tests/file_subscription/file_subscription.cpp b/config/src/tests/file_subscription/file_subscription.cpp index 27400ce57c9..69090f4bb8e 100644 --- a/config/src/tests/file_subscription/file_subscription.cpp +++ b/config/src/tests/file_subscription/file_subscription.cpp @@ -5,6 +5,7 @@ #include <vespa/config/file/filesource.h> #include <vespa/config/common/exceptions.h> #include <vespa/vespalib/util/sync.h> +#include <vespa/fastos/time.h> #include <fstream> #include <config-my.h> #include <config-foo.h> diff --git a/config/src/tests/subscriber/subscriber.cpp b/config/src/tests/subscriber/subscriber.cpp index 39a537486cd..5663b145100 100644 --- a/config/src/tests/subscriber/subscriber.cpp +++ b/config/src/tests/subscriber/subscriber.cpp @@ -5,6 +5,7 @@ #include <vespa/config/common/configholder.h> #include <vespa/config/subscription/configsubscription.h> #include <vespa/config/common/exceptions.h> +#include <vespa/fastos/time.h> #include <fstream> #include "config-foo.h" #include "config-bar.h" diff --git a/config/src/tests/subscription/subscription.cpp b/config/src/tests/subscription/subscription.cpp index a9e4c923e92..bfa341fa982 100644 --- a/config/src/tests/subscription/subscription.cpp +++ b/config/src/tests/subscription/subscription.cpp @@ -3,6 +3,7 @@ #include <vespa/config/common/misc.h> #include <vespa/config/common/configholder.h> #include <vespa/config/subscription/configsubscription.h> +#include <vespa/fastos/time.h> #include <config-my.h> using namespace config; diff --git a/config/src/vespa/config/common/configmanager.cpp b/config/src/vespa/config/common/configmanager.cpp index 2fa40b503df..0831853c2b4 100644 --- a/config/src/vespa/config/common/configmanager.cpp +++ b/config/src/vespa/config/common/configmanager.cpp @@ -2,6 +2,7 @@ #include "configmanager.h" #include "exceptions.h" #include "configholder.h" +#include <vespa/fastos/time.h> #include <thread> #include <sstream> diff --git a/config/src/vespa/config/common/trace.cpp b/config/src/vespa/config/common/trace.cpp index 09727d91fd9..2d9b3ce8370 100644 --- a/config/src/vespa/config/common/trace.cpp +++ b/config/src/vespa/config/common/trace.cpp @@ -2,6 +2,7 @@ #include "trace.h" #include <vespa/vespalib/trace/slime_trace_serializer.h> #include <vespa/vespalib/trace/slime_trace_deserializer.h> +#include <vespa/fastos/timestamp.h> using namespace vespalib; using namespace vespalib::slime; diff --git a/config/src/vespa/config/subscription/configsubscriptionset.cpp b/config/src/vespa/config/subscription/configsubscriptionset.cpp index 9b05535b22f..f120272edcf 100644 --- a/config/src/vespa/config/subscription/configsubscriptionset.cpp +++ b/config/src/vespa/config/subscription/configsubscriptionset.cpp @@ -3,7 +3,9 @@ #include "configsubscriptionset.h" #include <vespa/config/common/exceptions.h> #include <vespa/config/common/misc.h> +#include <vespa/fastos/time.h> #include <thread> + #include <vespa/log/log.h> LOG_SETUP(".config.subscription.configsubscriptionset"); diff --git a/fnet/src/tests/databuffer/databuffer.cpp b/fnet/src/tests/databuffer/databuffer.cpp index 94b59095be4..4bc3a6cb7a8 100644 --- a/fnet/src/tests/databuffer/databuffer.cpp +++ b/fnet/src/tests/databuffer/databuffer.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/fnet/databuffer.h> +#include <vespa/fastos/time.h> TEST("test resetIfEmpty") { FNET_DataBuffer buf(64); diff --git a/logd/src/tests/forward/forward.cpp b/logd/src/tests/forward/forward.cpp index a8da40555c7..e541297208b 100644 --- a/logd/src/tests/forward/forward.cpp +++ b/logd/src/tests/forward/forward.cpp @@ -2,6 +2,7 @@ #include <vespa/log/log.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/metrics/dummy_metrics_manager.h> +#include <vespa/fastos/time.h> #include <logd/forward.h> #include <logd/metrics.h> #include <sstream> diff --git a/messagebus/src/vespa/messagebus/routing/resender.h b/messagebus/src/vespa/messagebus/routing/resender.h index b99a3f8f0b3..93752dcfd5c 100644 --- a/messagebus/src/vespa/messagebus/routing/resender.h +++ b/messagebus/src/vespa/messagebus/routing/resender.h @@ -1,12 +1,13 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include "iretrypolicy.h" #include <vespa/messagebus/queue.h> #include <vespa/messagebus/reply.h> +#include <vespa/vespalib/util/sync.h> +#include <vespa/fastos/time.h> #include <queue> #include <vector> -#include <vespa/vespalib/util/sync.h> -#include "iretrypolicy.h" namespace mbus { diff --git a/searchcommon/src/vespa/searchcommon/common/schema.h b/searchcommon/src/vespa/searchcommon/common/schema.h index f8020d6ed9a..90cf099f2d8 100644 --- a/searchcommon/src/vespa/searchcommon/common/schema.h +++ b/searchcommon/src/vespa/searchcommon/common/schema.h @@ -6,6 +6,7 @@ #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/stllike/hash_map.h> #include <vespa/vespalib/util/ptrholder.h> +#include <vespa/fastos/timestamp.h> #include <vector> namespace vespalib { class asciistream; } diff --git a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp index a4992d57df3..fb80f6f55b4 100644 --- a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp +++ b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp @@ -1,14 +1,5 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <map> -#include <vespa/config-attributes.h> -#include <vespa/config-imported-fields.h> -#include <vespa/config-indexschema.h> -#include <vespa/config-rank-profiles.h> -#include <vespa/config-summary.h> -#include <vespa/config-summarymap.h> -#include <vespa/document/repo/documenttyperepo.h> -#include <vespa/fileacquirer/config-filedistributorrpc.h> #include <vespa/searchcore/proton/server/bootstrapconfig.h> #include <vespa/searchcore/proton/server/bootstrapconfigmanager.h> #include <vespa/searchcore/proton/server/documentdbconfigmanager.h> @@ -16,11 +7,21 @@ #include <vespa/searchcore/proton/server/proton_config_snapshot.h> #include <vespa/searchcore/proton/server/i_proton_configurer.h> #include <vespa/searchcore/proton/common/hw_info.h> -#include <vespa/searchsummary/config/config-juniperrc.h> #include <vespa/searchcore/config/config-ranking-constants.h> -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/searchsummary/config/config-juniperrc.h> +#include <vespa/document/repo/documenttyperepo.h> +#include <vespa/fileacquirer/config-filedistributorrpc.h> #include <vespa/vespalib/util/varholder.h> +#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/fastos/time.h> #include <vespa/config-bucketspaces.h> +#include <vespa/config-attributes.h> +#include <vespa/config-imported-fields.h> +#include <vespa/config-indexschema.h> +#include <vespa/config-rank-profiles.h> +#include <vespa/config-summary.h> +#include <vespa/config-summarymap.h> +#include <map> using namespace config; using namespace proton; @@ -148,14 +149,14 @@ struct ConfigTestFixture { } BootstrapConfig::SP getBootstrapConfig(int64_t generation, const HwInfo & hwInfo) const { - return BootstrapConfig::SP(new BootstrapConfig(generation, - std::make_shared<DocumenttypesConfig>(documenttypesBuilder), - std::make_shared<DocumentTypeRepo>(documenttypesBuilder), - std::make_shared<ProtonConfig>(protonBuilder), - std::make_shared<FiledistributorrpcConfig>(), - std::make_shared<BucketspacesConfig>(bucketspacesBuilder), - std::make_shared<TuneFileDocumentDB>(), - hwInfo)); + return std::make_shared<BootstrapConfig>(generation, + std::make_shared<DocumenttypesConfig>(documenttypesBuilder), + std::make_shared<DocumentTypeRepo>(documenttypesBuilder), + std::make_shared<ProtonConfig>(protonBuilder), + std::make_shared<FiledistributorrpcConfig>(), + std::make_shared<BucketspacesConfig>(bucketspacesBuilder), + std::make_shared<TuneFileDocumentDB>(), + hwInfo); } void reload() { context->reload(); } diff --git a/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.cpp b/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.cpp index a271e34b6b7..19175d1e2c7 100644 --- a/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.cpp @@ -2,6 +2,7 @@ #include "transactionlogmanagerbase.h" #include <vespa/vespalib/util/stringfmt.h> +#include <vespa/fastos/time.h> #include <vespa/log/log.h> LOG_SETUP(".proton.server.transactionlogmanagerbase"); diff --git a/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.h b/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.h index 6ba2b640fce..25add844d25 100644 --- a/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.h +++ b/searchcore/src/vespa/searchcore/proton/server/visibilityhandler.h @@ -7,6 +7,7 @@ #include <vespa/searchcore/proton/server/igetserialnum.h> #include <vespa/searchcorespi/index/ithreadingservice.h> #include <vespa/vespalib/util/varholder.h> +#include <vespa/fastos/timestamp.h> #include <mutex> namespace proton { diff --git a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp index 71467519dbd..2f69f0b45cf 100644 --- a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp +++ b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp @@ -18,6 +18,7 @@ #include <vespa/searchlib/diskindex/pagedict4file.h> #include <vespa/searchlib/diskindex/pagedict4randread.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/fastos/time.h> #include <vespa/fastos/app.h> #include <vespa/log/log.h> LOG_SETUP("fieldwriter_test"); diff --git a/searchlib/src/tests/fef/phrasesplitter/benchmark.cpp b/searchlib/src/tests/fef/phrasesplitter/benchmark.cpp index 500a032d967..c789fb582ec 100644 --- a/searchlib/src/tests/fef/phrasesplitter/benchmark.cpp +++ b/searchlib/src/tests/fef/phrasesplitter/benchmark.cpp @@ -1,6 +1,4 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/log/log.h> -LOG_SETUP("phrasesplitter_test"); #include <vespa/vespalib/testkit/testapp.h> #include <iomanip> @@ -8,9 +6,12 @@ LOG_SETUP("phrasesplitter_test"); #include <vespa/searchlib/fef/matchdatalayout.h> #include <vespa/searchlib/fef/phrasesplitter.h> #include <vespa/searchlib/fef/test/queryenvironment.h> +#include <vespa/fastos/time.h> + +#include <vespa/log/log.h> +LOG_SETUP("phrasesplitter_test"); -namespace search { -namespace fef { +namespace search::fef { class Benchmark : public vespalib::TestApp { @@ -80,6 +81,5 @@ Benchmark::Main() } } -} TEST_APPHOOK(search::fef::Benchmark); diff --git a/searchlib/src/tests/postinglistbm/andstress.cpp b/searchlib/src/tests/postinglistbm/andstress.cpp index 40f919509e8..15e56c2d4ef 100644 --- a/searchlib/src/tests/postinglistbm/andstress.cpp +++ b/searchlib/src/tests/postinglistbm/andstress.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 "andstress.h" -#include <vector> #include <vespa/searchlib/common/bitvector.h> #include <vespa/searchlib/test/fakedata/fakeword.h> @@ -13,8 +12,10 @@ #include <vespa/searchlib/test/fakedata/fakezcbfilterocc.h> #include <vespa/searchlib/test/fakedata/fpfactory.h> #include <vespa/fastos/thread.h> +#include <vespa/fastos/time.h> #include <mutex> #include <condition_variable> +#include <vector> #include <vespa/log/log.h> LOG_SETUP(".andstress"); diff --git a/searchlib/src/tests/transactionlogstress/translogstress.cpp b/searchlib/src/tests/transactionlogstress/translogstress.cpp index abba84b75b6..7a7bc410371 100644 --- a/searchlib/src/tests/transactionlogstress/translogstress.cpp +++ b/searchlib/src/tests/transactionlogstress/translogstress.cpp @@ -7,6 +7,7 @@ #include <vespa/searchlib/util/runnable.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/fastos/app.h> +#include <vespa/fastos/time.h> #include <iostream> #include <stdexcept> #include <sstream> diff --git a/searchlib/src/tests/util/bufferwriter/bm.cpp b/searchlib/src/tests/util/bufferwriter/bm.cpp index 3370860d2b6..b19a7390e9c 100644 --- a/searchlib/src/tests/util/bufferwriter/bm.cpp +++ b/searchlib/src/tests/util/bufferwriter/bm.cpp @@ -1,11 +1,13 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/log/log.h> -LOG_SETUP("bufferwriter_bm"); -#include <vespa/vespalib/testkit/testapp.h> -#include <iostream> #include "work.h" #include <vespa/searchlib/util/drainingbufferwriter.h> +#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/fastos/timestamp.h> +#include <iostream> + +#include <vespa/log/log.h> +LOG_SETUP("bufferwriter_bm"); using search::DrainingBufferWriter; diff --git a/searchlib/src/vespa/searchlib/docstore/filechunk.h b/searchlib/src/vespa/searchlib/docstore/filechunk.h index 87dc2e018eb..7d79760a61c 100644 --- a/searchlib/src/vespa/searchlib/docstore/filechunk.h +++ b/searchlib/src/vespa/searchlib/docstore/filechunk.h @@ -7,11 +7,12 @@ #include "lid_info.h" #include "randread.h" #include <vespa/searchlib/util/memoryusage.h> +#include <vespa/searchlib/common/tunefileinfo.h> #include <vespa/vespalib/util/ptrholder.h> #include <vespa/vespalib/util/sync.h> #include <vespa/vespalib/stllike/hash_map.h> -#include <vespa/searchlib/common/tunefileinfo.h> #include <vespa/vespalib/util/generationhandler.h> +#include <vespa/fastos/timestamp.h> class FastOS_FileInterface; diff --git a/searchlib/src/vespa/searchlib/features/debug_attribute_wait.cpp b/searchlib/src/vespa/searchlib/features/debug_attribute_wait.cpp index 20de658f7f6..99645cc3338 100644 --- a/searchlib/src/vespa/searchlib/features/debug_attribute_wait.cpp +++ b/searchlib/src/vespa/searchlib/features/debug_attribute_wait.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 "debug_attribute_wait.h" +#include <vespa/fastos/time.h> #include <thread> using search::attribute::IAttributeVector; diff --git a/searchlib/src/vespa/searchlib/features/debug_wait.cpp b/searchlib/src/vespa/searchlib/features/debug_wait.cpp index 565ca27a759..6a26b24b451 100644 --- a/searchlib/src/vespa/searchlib/features/debug_wait.cpp +++ b/searchlib/src/vespa/searchlib/features/debug_wait.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 "debug_wait.h" +#include <vespa/fastos/time.h> #include <thread> namespace search { diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp index b4009f1e6b0..1f8ea9fb2ea 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp @@ -2,6 +2,7 @@ #include "fakewordset.h" #include "fakeword.h" +#include <vespa/fastos/time.h> #include <sstream> #include <vespa/log/log.h> diff --git a/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.cpp b/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.cpp index fe708f52a93..2cb546395d3 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.cpp @@ -3,6 +3,7 @@ #include "trans_log_server_explorer.h" #include <vespa/vespalib/data/slime/slime.h> #include <vespa/fastos/file.h> +#include <vespa/fastos/timestamp.h> using vespalib::slime::Inserter; diff --git a/staging_vespalib/src/tests/directio/directio.cpp b/staging_vespalib/src/tests/directio/directio.cpp index cca884333f0..04155f71f94 100644 --- a/staging_vespalib/src/tests/directio/directio.cpp +++ b/staging_vespalib/src/tests/directio/directio.cpp @@ -5,7 +5,6 @@ #include <vespa/vespalib/data/databuffer.h> #include <vespa/fastos/file.h> -using namespace fastos; using namespace vespalib; TEST("that DirectIOException propagates the correct information.") { diff --git a/storage/src/vespa/storage/tools/throttlingsim.cpp b/storage/src/vespa/storage/tools/throttlingsim.cpp index cd3c0c1cea4..97f5af3518e 100644 --- a/storage/src/vespa/storage/tools/throttlingsim.cpp +++ b/storage/src/vespa/storage/tools/throttlingsim.cpp @@ -1,8 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "throttlingsim.h" -#include <algorithm> #include <vespa/vespalib/util/stringfmt.h> +#include <algorithm> #include <unistd.h> bool Receiver::enqueue(const Message& msg) { diff --git a/storage/src/vespa/storage/tools/throttlingsim.h b/storage/src/vespa/storage/tools/throttlingsim.h index c468f1879a3..dc36a5b9206 100644 --- a/storage/src/vespa/storage/tools/throttlingsim.h +++ b/storage/src/vespa/storage/tools/throttlingsim.h @@ -3,6 +3,7 @@ #include <vespa/vespalib/util/sync.h> #include <vespa/vespalib/util/document_runnable.h> #include <vespa/fastos/app.h> +#include <vespa/fastos/time.h> #include <deque> #include <vector> diff --git a/vdslib/src/tests/distribution/distributiontest.cpp b/vdslib/src/tests/distribution/distributiontest.cpp index 7af48c1904b..5408c714eba 100644 --- a/vdslib/src/tests/distribution/distributiontest.cpp +++ b/vdslib/src/tests/distribution/distributiontest.cpp @@ -681,14 +681,11 @@ DistributionTest::testSkew() ClusterState systemState("storage:50"); - Distribution distr( - Distribution::getDefaultDistributionConfig(copies, nodes)); + Distribution distr(Distribution::getDefaultDistributionConfig(copies, nodes)); std::vector<std::pair<uint64_t, std::vector<uint16_t> > > _distribution(buckets); std::vector<int> _nodeCount(nodes, 0); - FastOS_Time start; - start.SetNow(); for (int i = 0; i < buckets; i++) { _distribution[i].first = i * 100; _distribution[i].second = distr.getIdealStorageNodes( @@ -708,9 +705,6 @@ DistributionTest::testSkew() fprintf(stderr, "%d ", _nodeCount[i]); } - double elapsed = start.MilliSecsToNow(); - fprintf(stderr, "%d calcs in %f ms = %f calcs/sec\n", - buckets, elapsed, double(buckets * 1000) / elapsed); */ sort(_nodeCount.begin(), _nodeCount.end()); @@ -859,8 +853,6 @@ DistributionTest::testSkewWithDown() _distribution[i].second.reserve(copies); } - FastOS_Time start; - start.SetNow(); for (int i = 0; i < buckets; i++) { _distribution[i].first = i * 100; _distribution[i].second = distr.getIdealStorageNodes( @@ -875,10 +867,6 @@ DistributionTest::testSkewWithDown() } } /* - double elapsed = start.MilliSecsToNow(); - fprintf(stderr, "%d calcs in %f ms = %f calcs/sec\n", - buckets, elapsed, double(buckets * 1000) / elapsed); - // Check distribution for (int i = 0; i < nodes; i++) { fprintf(stderr, "%d ", _nodeCount[i]); diff --git a/vespalib/src/tests/executor/stress_test.cpp b/vespalib/src/tests/executor/stress_test.cpp index 5c7620afb14..702991fd779 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 <vespa/fastos/time.h> using namespace vespalib; using namespace std::literals; diff --git a/vespalib/src/tests/left_right_heap/left_right_heap_bench.cpp b/vespalib/src/tests/left_right_heap/left_right_heap_bench.cpp index dd031f0c2ce..e6fdab7d773 100644 --- a/vespalib/src/tests/left_right_heap/left_right_heap_bench.cpp +++ b/vespalib/src/tests/left_right_heap/left_right_heap_bench.cpp @@ -3,6 +3,7 @@ #include <vespa/vespalib/util/left_right_heap.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/util/inline.h> +#include <vespa/fastos/time.h> using namespace vespalib; 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 688261af3e7..b113e7a2284 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 <vespa/fastos/time.h> using namespace vespalib; diff --git a/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp b/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp index df5b239e341..2a58f1df382 100644 --- a/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp +++ b/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/data/slime/slime.h> +#include <vespa/fastos/time.h> using namespace vespalib; using namespace vespalib::slime::convenience; diff --git a/vespalib/src/vespa/vespalib/util/sync.h b/vespalib/src/vespa/vespalib/util/sync.h index e3f3d44122c..6461eaf9c3f 100644 --- a/vespalib/src/vespa/vespalib/util/sync.h +++ b/vespalib/src/vespa/vespalib/util/sync.h @@ -2,13 +2,11 @@ #pragma once -#include <vespa/fastos/time.h> #include <cassert> #include <mutex> #include <condition_variable> #include <chrono> - namespace vespalib { /** @@ -362,13 +360,12 @@ public: void unlock() { assert(_guard); _guard.unlock(); - _cond = NULL; + _cond = nullptr; } /** * @brief Wait for a signal on the underlying Monitor. **/ void wait() { - assert(_cond != NULL); _cond->wait(_guard); } /** @@ -379,7 +376,6 @@ public: * @return true if a signal was received, false if the wait timed out. **/ bool wait(int msTimeout) { - assert(_cond != NULL); return _cond->wait_for(_guard, std::chrono::milliseconds(msTimeout)) == std::cv_status::no_timeout; } /** @@ -387,14 +383,12 @@ public: * Monitor. **/ void signal() { - assert(_cond != NULL); _cond->notify_one(); } /** * @brief Send a signal to all waiters on the underlying Monitor. **/ void broadcast() { - assert(_cond != NULL); _cond->notify_all(); } /** @@ -406,10 +400,9 @@ public: * will live long enough to be signaled. **/ void unsafeSignalUnlock() { - assert(_cond != NULL); _guard.unlock(); _cond->notify_one(); - _cond = NULL; + _cond = nullptr; } /** * @brief Send a signal to all waiters on the underlying Monitor, @@ -420,10 +413,9 @@ public: * will live long enough to be signaled. **/ void unsafeBroadcastUnlock() { - assert(_cond != NULL); _guard.unlock(); _cond->notify_all(); - _cond = NULL; + _cond = nullptr; } /** * @brief Release the lock held by this object if unlock has not @@ -436,94 +428,7 @@ public: * guard ref as input, ensuring that the caller have grabbed a lock. */ bool monitors(const Monitor& m) const { - return (_cond != NULL && _cond == &m._cond); - } -}; - - -/** - * Helper class that can be used to wait for a condition when having a - * constraint on how long you want to wait. The usage is best - * explained with an example: - * - * <pre> - * bool waitForWantedState(int maxwait) { - * MonitorGuard guard(_monitor); - * TimedWaiter waiter(guard, maxwait); - * while (!wantedState && waiter.hasTime()) { - * waiter.wait(); - * } - * return wantedState; - * } - * </pre> - * - * The example code will limit the total wait time to maxwait - * milliseconds across all blocking wait operations on the underlying - * monitor guard. - **/ -class TimedWaiter -{ -private: - MonitorGuard &_guard; - FastOS_Time _start; - int _maxwait; - int _remain; - bool _timeout; - - TimedWaiter(const TimedWaiter&); - TimedWaiter &operator=(const TimedWaiter&); -public: - - /** - * Create a new instance using the given monitor guard and wait - * time limit. If the maximum time is less than or equal to 0, the - * wait will time out immediately and no low-level wait operations - * will be performed. - * - * @param guard the underlying monitor guard used to perform the actual wait operation. - * @param maxwait maximum time to wait in milliseconds. - **/ - TimedWaiter(MonitorGuard &guard, int maxwait) - : _guard(guard), _start(), _maxwait(maxwait), _remain(0), _timeout(false) - { - if (_maxwait > 0) { - _start.SetNow(); - } else { - _timeout = true; - } - } - - /** - * Check if this object has any time left until the time limit is - * exceeded. - * - * @return true if there is time left. - **/ - bool hasTime() const { - return !_timeout; - } - - /** - * Perform low-level wait in such a way that we do not exceed the - * maximum total wait time. This method also performs the needed - * book-keeping to keep track of elapsed time between invocations. - * - * @return true if we woke up due to a signal, false if we timed out. - **/ - bool wait() { - if (!_timeout) { - if (_remain > 0) { - _remain = (_maxwait - (int)_start.MilliSecsToNow()); - } else { - _remain = _maxwait; - } - if (_remain > 0) { - _timeout = !_guard.wait(_remain); - } else { - _timeout = true; - } - } - return !_timeout; + return (_cond != nullptr && _cond == &m._cond); } }; |