diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-05-03 13:09:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-03 13:09:06 +0200 |
commit | 5064823c52fe2cfe162798061b2a2f7133f9b931 (patch) | |
tree | b5db5d360faf893158f6cd1b3159e99e9c6b8e1e /vespalib | |
parent | 9a5239261e5b90fd9dc06d291f4a44c5fb663639 (diff) |
Revert "Fix warnings hidden earlier due to including application headers as s…"
Diffstat (limited to 'vespalib')
31 files changed, 160 insertions, 191 deletions
diff --git a/vespalib/src/tests/alloc/alloc_test.cpp b/vespalib/src/tests/alloc/alloc_test.cpp index 11372c0aebd..5da06091796 100644 --- a/vespalib/src/tests/alloc/alloc_test.cpp +++ b/vespalib/src/tests/alloc/alloc_test.cpp @@ -1,9 +1,11 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - +#include <vespa/fastos/fastos.h> +#include <stddef.h> +#include <vespa/log/log.h> +LOG_SETUP("alloc_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/alloc.h> #include <vespa/vespalib/util/exceptions.h> -#include <cstddef> using namespace vespalib; using namespace vespalib::alloc; @@ -14,11 +16,11 @@ testSwap(T & a, T & b) { void * tmpA(a.get()); void * tmpB(b.get()); - EXPECT_EQUAL(4096ul, a.size()); - EXPECT_EQUAL(8192ul, b.size()); + EXPECT_EQUAL(4096u, a.size()); + EXPECT_EQUAL(8192, b.size()); std::swap(a, b); - EXPECT_EQUAL(4096ul, b.size()); - EXPECT_EQUAL(8192ul, a.size()); + EXPECT_EQUAL(4096u, b.size()); + EXPECT_EQUAL(8192, a.size()); EXPECT_EQUAL(tmpA, b.get()); EXPECT_EQUAL(tmpB, a.get()); } @@ -85,46 +87,46 @@ TEST("no rounding of small heap buffer") { TEST("no rounding of large heap buffer") { Alloc buf = Alloc::alloc(MemoryAllocator::HUGEPAGE_SIZE*11+3, MemoryAllocator::HUGEPAGE_SIZE*16); - EXPECT_EQUAL(size_t(MemoryAllocator::HUGEPAGE_SIZE*11+3), buf.size()); + EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE*11+3, buf.size()); } TEST("rounding of small mmaped buffer") { Alloc buf = Alloc::alloc(MemoryAllocator::HUGEPAGE_SIZE); EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE, buf.size()); buf = Alloc::alloc(MemoryAllocator::HUGEPAGE_SIZE+1); - EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE*2ul, buf.size()); + EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE*2, buf.size()); } TEST("rounding of large mmaped buffer") { Alloc buf = Alloc::alloc(MemoryAllocator::HUGEPAGE_SIZE*11+3); - EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE*12ul, buf.size()); + EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE*12, buf.size()); } TEST("heap alloc can not be extended") { Alloc buf = Alloc::allocHeap(100); void * oldPtr = buf.get(); - EXPECT_EQUAL(100ul, buf.size()); + EXPECT_EQUAL(100, buf.size()); EXPECT_FALSE(buf.resize_inplace(101)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(100ul, buf.size()); + EXPECT_EQUAL(100, buf.size()); } TEST("auto alloced heap alloc can not be extended") { Alloc buf = Alloc::alloc(100); void * oldPtr = buf.get(); - EXPECT_EQUAL(100ul, buf.size()); + EXPECT_EQUAL(100, buf.size()); EXPECT_FALSE(buf.resize_inplace(101)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(100ul, buf.size()); + EXPECT_EQUAL(100, buf.size()); } TEST("auto alloced heap alloc can not be extended, even if resize will be mmapped") { Alloc buf = Alloc::alloc(100); void * oldPtr = buf.get(); - EXPECT_EQUAL(100ul, buf.size()); + EXPECT_EQUAL(100, buf.size()); EXPECT_FALSE(buf.resize_inplace(MemoryAllocator::HUGEPAGE_SIZE*3)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(100ul, buf.size()); + EXPECT_EQUAL(100, buf.size()); } TEST("auto alloced mmap alloc can be extended if room") { @@ -181,10 +183,10 @@ TEST("mmap alloc can be extended if room") { } void * oldPtr = buf.get(); - EXPECT_EQUAL(4096ul, buf.size()); + EXPECT_EQUAL(4096, buf.size()); EXPECT_TRUE(buf.resize_inplace(4097)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(8192ul, buf.size()); + EXPECT_EQUAL(8192, buf.size()); } TEST("mmap alloc can not be extended if no room") { @@ -197,37 +199,37 @@ TEST("mmap alloc can not be extended if no room") { EXPECT_EQUAL(reserved.get(), static_cast<const char *>(buf.get()) + buf.size()); void * oldPtr = buf.get(); - EXPECT_EQUAL(4096ul, buf.size()); + EXPECT_EQUAL(4096, buf.size()); EXPECT_FALSE(buf.resize_inplace(4097)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(4096ul, buf.size()); + EXPECT_EQUAL(4096, buf.size()); } TEST("heap alloc can not be shrinked") { Alloc buf = Alloc::allocHeap(101); void * oldPtr = buf.get(); - EXPECT_EQUAL(101ul, buf.size()); + EXPECT_EQUAL(101, buf.size()); EXPECT_FALSE(buf.resize_inplace(100)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(101ul, buf.size()); + EXPECT_EQUAL(101, buf.size()); } TEST("mmap alloc can be shrinked") { Alloc buf = Alloc::allocMMap(4097); void * oldPtr = buf.get(); - EXPECT_EQUAL(8192ul, buf.size()); + EXPECT_EQUAL(8192, buf.size()); EXPECT_TRUE(buf.resize_inplace(4095)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(4096ul, buf.size()); + EXPECT_EQUAL(4096, buf.size()); } TEST("auto alloced heap alloc can not be shrinked") { Alloc buf = Alloc::alloc(101); void * oldPtr = buf.get(); - EXPECT_EQUAL(101ul, buf.size()); + EXPECT_EQUAL(101, buf.size()); EXPECT_FALSE(buf.resize_inplace(100)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(101ul, buf.size()); + EXPECT_EQUAL(101, buf.size()); } TEST("auto alloced mmap alloc can be shrinked") { diff --git a/vespalib/src/tests/data/input_reader/input_reader_test.cpp b/vespalib/src/tests/data/input_reader/input_reader_test.cpp index 444f57809f7..9ef127be364 100644 --- a/vespalib/src/tests/data/input_reader/input_reader_test.cpp +++ b/vespalib/src/tests/data/input_reader/input_reader_test.cpp @@ -3,6 +3,7 @@ #include <vespa/vespalib/data/memory_input.h> #include <vespa/vespalib/data/input_reader.h> #include <vespa/vespalib/test/chunked_input.h> +#include <algorithm> using namespace vespalib; using vespalib::test::ChunkedInput; @@ -91,12 +92,12 @@ TEST("expect that obtain does not set failure state on input reader") { for (bool byte_first: {true, false}) { MemoryInput input(data); InputReader src(input); - EXPECT_EQUAL(src.obtain(), 5u); - EXPECT_EQUAL(src.obtain(), 5u); + EXPECT_EQUAL(src.obtain(), 5); + EXPECT_EQUAL(src.obtain(), 5); EXPECT_EQUAL(src.read(5), Memory("12345")); EXPECT_TRUE(!src.failed()); - EXPECT_EQUAL(src.obtain(), 0u); - EXPECT_EQUAL(src.obtain(), 0u); + EXPECT_EQUAL(src.obtain(), 0); + EXPECT_EQUAL(src.obtain(), 0); EXPECT_TRUE(!src.failed()); if (byte_first) { EXPECT_EQUAL(src.read(), 0); @@ -108,7 +109,7 @@ TEST("expect that obtain does not set failure state on input reader") { EXPECT_EQUAL(src.read(), 0); } EXPECT_EQUAL(src.get_error_message(), vespalib::string("input underflow")); - EXPECT_EQUAL(src.obtain(), 0u); + EXPECT_EQUAL(src.obtain(), 0); } } diff --git a/vespalib/src/tests/data/memory_input/memory_input_test.cpp b/vespalib/src/tests/data/memory_input/memory_input_test.cpp index fa41961e22a..a62283500f0 100644 --- a/vespalib/src/tests/data/memory_input/memory_input_test.cpp +++ b/vespalib/src/tests/data/memory_input/memory_input_test.cpp @@ -7,7 +7,7 @@ using namespace vespalib; TEST("require that MemoryInput wrapper works as expected") { const char *data = "1234567890"; Memory memory(data); - EXPECT_EQUAL(memory.size, 10u); + EXPECT_EQUAL(memory.size, 10); MemoryInput input(memory); EXPECT_EQUAL(input.obtain(), memory); input.evict(5); diff --git a/vespalib/src/tests/data/output_writer/output_writer_test.cpp b/vespalib/src/tests/data/output_writer/output_writer_test.cpp index 72e3751b279..3d59b2fcb1e 100644 --- a/vespalib/src/tests/data/output_writer/output_writer_test.cpp +++ b/vespalib/src/tests/data/output_writer/output_writer_test.cpp @@ -46,7 +46,7 @@ TEST("require that large printf works") { "12345678901234567890123456789012345678901234567890" "12345678901234567890123456789012345678901234567890"; size_t str_len = strlen(str); - EXPECT_EQUAL(str_len, 200u); + EXPECT_EQUAL(str_len, 200); SimpleBuffer buffer; { OutputWriter dst(buffer, 3); diff --git a/vespalib/src/tests/net/socket/socket_test.cpp b/vespalib/src/tests/net/socket/socket_test.cpp index b4b0ce1e31f..55ef70d2d61 100644 --- a/vespalib/src/tests/net/socket/socket_test.cpp +++ b/vespalib/src/tests/net/socket/socket_test.cpp @@ -51,7 +51,7 @@ void replace_file(const vespalib::string &path, const vespalib::string &data) { remove_file(path); int fd = creat(path.c_str(), 0600); ASSERT_NOT_EQUAL(fd, -1); - ASSERT_EQUAL(write(fd, data.data(), data.size()), ssize_t(data.size())); + ASSERT_EQUAL(write(fd, data.data(), data.size()), data.size()); close(fd); } @@ -94,12 +94,12 @@ void verify_socket_io(bool is_server, SocketHandle &socket) { vespalib::string client_message = "please pick up, I need to talk to you"; if(is_server) { ssize_t written = socket.write(server_message.data(), server_message.size()); - EXPECT_EQUAL(written, ssize_t(server_message.size())); + EXPECT_EQUAL(written, server_message.size()); vespalib::string read = read_bytes(socket, client_message.size()); EXPECT_EQUAL(client_message, read); } else { ssize_t written = socket.write(client_message.data(), client_message.size()); - EXPECT_EQUAL(written, ssize_t(client_message.size())); + EXPECT_EQUAL(written, client_message.size()); vespalib::string read = read_bytes(socket, server_message.size()); EXPECT_EQUAL(server_message, read); } diff --git a/vespalib/src/tests/stash/stash.cpp b/vespalib/src/tests/stash/stash.cpp index 3c6fabd8264..931c612c1d3 100644 --- a/vespalib/src/tests/stash/stash.cpp +++ b/vespalib/src/tests/stash/stash.cpp @@ -365,7 +365,7 @@ TEST("require that arrays can be copied into the stash") { ArrayRef<PairD> pair_array = stash.copy_array<PairD>(ConstArrayRef<PairD>(paird_vector)); ASSERT_EQUAL(pair_array_nodelete.size(), 3u); ASSERT_EQUAL(pair_array.size(), 3u); - for (int i = 0; i < 3; ++i) { + for (size_t i = 0; i < 3; ++i) { ASSERT_EQUAL(pair_array_nodelete[i].a, i + 1); ASSERT_EQUAL(pair_array_nodelete[i].b, i + 1.5); ASSERT_EQUAL(pair_array[i].a, i + 1); @@ -382,11 +382,11 @@ TEST("require that created arrays are destructed (or not) correctly") { EXPECT_EQUAL(sum({chunk_header_size(), array_dtor_hook_size(), 5 * sizeof(Small)}), stash.count_used()); stash.create_array<Small_NoDelete>(7,destruct_nodelete); EXPECT_EQUAL(sum({chunk_header_size(), array_dtor_hook_size(), 5 * sizeof(Small), 7 * sizeof(Small_NoDelete)}), stash.count_used()); - EXPECT_EQUAL(0u, destruct); - EXPECT_EQUAL(0u, destruct_nodelete); + EXPECT_EQUAL(0, destruct); + EXPECT_EQUAL(0, destruct_nodelete); } - EXPECT_EQUAL(5u, destruct); - EXPECT_EQUAL(0u, destruct_nodelete); + EXPECT_EQUAL(5, destruct); + EXPECT_EQUAL(0, destruct_nodelete); } TEST("require that copied arrays are destructed (or not) correctly") { diff --git a/vespalib/src/tests/sync/sync_test.cpp b/vespalib/src/tests/sync/sync_test.cpp index 54fa65daea6..16c044a9902 100644 --- a/vespalib/src/tests/sync/sync_test.cpp +++ b/vespalib/src/tests/sync/sync_test.cpp @@ -18,12 +18,10 @@ private: LockGuard lockMonitor() { return LockGuard(_monitor); } MonitorGuard obtainMonitor() { return MonitorGuard(_monitor); } public: - ~Test(); void testCountDownLatch(); int Main() override; }; -Test::~Test() {} void Test::testCountDownLatch() { { diff --git a/vespalib/src/vespa/vespalib/component/version.cpp b/vespalib/src/vespa/vespalib/component/version.cpp index 8bccf6c969d..8e385b74eae 100644 --- a/vespalib/src/vespa/vespalib/component/version.cpp +++ b/vespalib/src/vespa/vespalib/component/version.cpp @@ -3,6 +3,7 @@ #include "version.h" #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <cctype> #include <climits> namespace vespalib { @@ -18,8 +19,6 @@ Version::Version(int major, int minor, int micro, const string & qualifier) initialize(); } -Version::Version(const Version &) = default; -Version & Version::operator = (const Version &) = default; Version::~Version() { } void diff --git a/vespalib/src/vespa/vespalib/component/version.h b/vespalib/src/vespa/vespalib/component/version.h index 34e5bcc818c..58c680ce8f1 100644 --- a/vespalib/src/vespa/vespalib/component/version.h +++ b/vespalib/src/vespa/vespalib/component/version.h @@ -60,8 +60,6 @@ public: */ Version(int major = 0, int minor = 0, int micro = 0, const string & qualifier = ""); - Version(const Version &); - Version & operator = (const Version &); ~Version(); /** diff --git a/vespalib/src/vespa/vespalib/data/slime/binary_format.cpp b/vespalib/src/vespa/vespalib/data/slime/binary_format.cpp index c9b1c4c37e5..2b7460933cf 100644 --- a/vespalib/src/vespa/vespalib/data/slime/binary_format.cpp +++ b/vespalib/src/vespa/vespalib/data/slime/binary_format.cpp @@ -1,7 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "binary_format.h" +#include "inserter.h" #include "slime.h" +#include <vespa/vespalib/util/array.hpp> #include <vespa/vespalib/data/memory_input.h> namespace vespalib { @@ -263,27 +265,5 @@ BinaryFormat::decode_into(const Memory &memory, Slime &slime, const Inserter &in return binary_format::decode<true>(memory, slime, inserter); } -namespace binary_format { - -void -write_cmpr_ulong(OutputWriter &out, uint64_t value) { - out.commit(encode_cmpr_ulong(out.reserve(10), value)); -} - -void -write_type_and_size(OutputWriter &out, uint32_t type, uint64_t size) { - char *start = out.reserve(11); // max size - char *pos = start; - if (size <= 30) { - *pos++ = encode_type_and_meta(type, size + 1); - } else { - *pos++ = encode_type_and_meta(type, 0); - pos += encode_cmpr_ulong(pos, size); - } - out.commit(pos - start); -} - -} - } // namespace vespalib::slime } // namespace vespalib diff --git a/vespalib/src/vespa/vespalib/data/slime/binary_format.h b/vespalib/src/vespa/vespalib/data/slime/binary_format.h index 39fc3c5d688..df6e32a0b22 100644 --- a/vespalib/src/vespa/vespalib/data/slime/binary_format.h +++ b/vespalib/src/vespa/vespalib/data/slime/binary_format.h @@ -2,12 +2,12 @@ #pragma once -#include "type.h" -#include "inserter.h" +#include <string> #include <vespa/vespalib/data/output.h> +#include "type.h" #include <vespa/vespalib/data/input_reader.h> #include <vespa/vespalib/data/output_writer.h> -#include <string> +#include "inserter.h" namespace vespalib { @@ -55,10 +55,9 @@ inline uint32_t decode_meta(uint32_t type_and_meta) { return ((type_and_meta >> 3) & 0x1f); } - -void write_cmpr_ulong(OutputWriter &out, uint64_t value); - -inline uint32_t encode_cmpr_ulong(char *out, uint64_t value) { +inline uint32_t encode_cmpr_ulong(char *out, + uint64_t value) +{ // pre-req: out has room for 10 bytes char *pos = out; char next = (value & 0x7f); @@ -72,7 +71,14 @@ inline uint32_t encode_cmpr_ulong(char *out, uint64_t value) { return (pos - out); } -inline uint64_t read_cmpr_ulong(InputReader &in) { +inline void write_cmpr_ulong(OutputWriter &out, + uint64_t value) +{ + out.commit(encode_cmpr_ulong(out.reserve(10), value)); +} + +inline uint64_t read_cmpr_ulong(InputReader &in) +{ uint64_t next = in.read(); uint64_t value = (next & 0x7f); int shift = 7; @@ -84,7 +90,19 @@ inline uint64_t read_cmpr_ulong(InputReader &in) { return value; } -void write_type_and_size(OutputWriter &out, uint32_t type, uint64_t size); +inline void write_type_and_size(OutputWriter &out, + uint32_t type, uint64_t size) +{ + char *start = out.reserve(11); // max size + char *pos = start; + if (size <= 30) { + *pos++ = encode_type_and_meta(type, size + 1); + } else { + *pos++ = encode_type_and_meta(type, 0); + pos += encode_cmpr_ulong(pos, size); + } + out.commit(pos - start); +} inline uint64_t read_size(InputReader &in, uint32_t meta) { @@ -92,8 +110,8 @@ inline uint64_t read_size(InputReader &in, uint32_t meta) } template <bool top> -void write_type_and_bytes(OutputWriter &out, - uint32_t type, uint64_t bits) +inline void write_type_and_bytes(OutputWriter &out, + uint32_t type, uint64_t bits) { char *start = out.reserve(9); // max size char *pos = start + 1; @@ -111,7 +129,8 @@ void write_type_and_bytes(OutputWriter &out, } template <bool top> -uint64_t read_bytes(InputReader &in, uint32_t bytes) +inline uint64_t read_bytes(InputReader &in, + uint32_t bytes) { uint64_t value = 0; int shift = top ? 56 : 0; @@ -131,3 +150,4 @@ uint64_t read_bytes(InputReader &in, uint32_t bytes) } // namespace vespalib::slime } // namespace vespalib + diff --git a/vespalib/src/vespa/vespalib/io/fileutil.cpp b/vespalib/src/vespa/vespalib/io/fileutil.cpp index 2794a519800..192dcf7c413 100644 --- a/vespalib/src/vespa/vespalib/io/fileutil.cpp +++ b/vespalib/src/vespa/vespalib/io/fileutil.cpp @@ -610,11 +610,6 @@ lstat(const stringref & path) } bool -fileExists(const vespalib::stringref & path) { - return (stat(path).get() != 0); -} - -bool unlink(const stringref & filename) { if (::unlink(filename.c_str()) != 0) { diff --git a/vespalib/src/vespa/vespalib/io/fileutil.h b/vespalib/src/vespa/vespalib/io/fileutil.h index 3984ec796c8..8ad05c96152 100644 --- a/vespalib/src/vespa/vespalib/io/fileutil.h +++ b/vespalib/src/vespa/vespalib/io/fileutil.h @@ -28,6 +28,7 @@ #pragma once #include <unistd.h> +#include <string> #include <memory> #include <vector> #include <vespa/vespalib/stllike/string.h> @@ -318,7 +319,9 @@ extern FileInfo::UP lstat(const vespalib::stringref & path); * * @throw IoException If we failed to stat the file. */ -extern bool fileExists(const vespalib::stringref & path); +extern inline bool fileExists(const vespalib::stringref & path) { + return (stat(path).get() != 0); +} /** * Check if a path exists, i.e. whether it's a symbolic link, regular file, @@ -449,3 +452,4 @@ string dirname(const stringref name); string getOpenErrorString(const int osError, const stringref name); } // vespalib + diff --git a/vespalib/src/vespa/vespalib/testkit/generated_fixture_macros.h b/vespalib/src/vespa/vespalib/testkit/generated_fixture_macros.h index 94fc392bcdd..438b8bbcdf0 100644 --- a/vespalib/src/vespa/vespalib/testkit/generated_fixture_macros.h +++ b/vespalib/src/vespa/vespalib/testkit/generated_fixture_macros.h @@ -8,9 +8,9 @@ namespace { \ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ TEST_CAT(TestKitHook, __LINE__)() : vespalib::TestHook(__FILE__, name, ignore) {} \ struct Test : vespalib::TestFixtureWrapper { \ - void test_entry_point() override; \ + virtual void test_entry_point(); \ }; \ - bool run() override { \ + virtual bool run() { \ TEST_STATE(name); \ Test test; \ return runTest(test, threads); \ @@ -42,7 +42,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ F1 &f; \ F1 &f1; \ Test(F1 &f1_in) : f(f1_in), f1(f1_in) {} \ - void test_entry_point() override; \ + virtual void test_entry_point(); \ }; \ template <typename F1> \ bool dispatch1(F1 *_f1_ptr_) { \ @@ -51,7 +51,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ Test<F1> test(f1); \ return runTest(test, threads); \ } \ - bool run() override { \ + virtual bool run() { \ TEST_STATE(name); \ size_t num_threads(threads); (void) num_threads; \ return dispatch1(new fixture1); \ @@ -84,7 +84,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ F1 &f1; \ F2 &f2; \ Test(F1 &f1_in, F2 &f2_in) : f1(f1_in), f2(f2_in) {} \ - void test_entry_point() override; \ + virtual void test_entry_point(); \ }; \ template <typename F1, typename F2> \ bool dispatch2(F1 &f1, F2 *_f2_ptr_) { \ @@ -100,7 +100,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ size_t num_threads(threads); (void) num_threads; \ return dispatch2(f1, new fixture2); \ } \ - bool run() override { \ + virtual bool run() { \ TEST_STATE(name); \ size_t num_threads(threads); (void) num_threads; \ return dispatch1(new fixture1); \ @@ -134,7 +134,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ F2 &f2; \ F3 &f3; \ Test(F1 &f1_in, F2 &f2_in, F3 &f3_in) : f1(f1_in), f2(f2_in), f3(f3_in) {} \ - void test_entry_point() override; \ + virtual void test_entry_point(); \ }; \ template <typename F1, typename F2, typename F3> \ bool dispatch3(F1 &f1, F2 &f2, F3 *_f3_ptr_) { \ @@ -157,7 +157,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ size_t num_threads(threads); (void) num_threads; \ return dispatch2(f1, new fixture2); \ } \ - bool run() override { \ + virtual bool run() { \ TEST_STATE(name); \ size_t num_threads(threads); (void) num_threads; \ return dispatch1(new fixture1); \ @@ -192,7 +192,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ F3 &f3; \ F4 &f4; \ Test(F1 &f1_in, F2 &f2_in, F3 &f3_in, F4 &f4_in) : f1(f1_in), f2(f2_in), f3(f3_in), f4(f4_in) {} \ - void test_entry_point() override; \ + virtual void test_entry_point(); \ }; \ template <typename F1, typename F2, typename F3, typename F4> \ bool dispatch4(F1 &f1, F2 &f2, F3 &f3, F4 *_f4_ptr_) { \ @@ -222,7 +222,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ size_t num_threads(threads); (void) num_threads; \ return dispatch2(f1, new fixture2); \ } \ - bool run() override { \ + virtual bool run() { \ TEST_STATE(name); \ size_t num_threads(threads); (void) num_threads; \ return dispatch1(new fixture1); \ @@ -258,7 +258,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ F4 &f4; \ F5 &f5; \ Test(F1 &f1_in, F2 &f2_in, F3 &f3_in, F4 &f4_in, F5 &f5_in) : f1(f1_in), f2(f2_in), f3(f3_in), f4(f4_in), f5(f5_in) {} \ - void test_entry_point() override; \ + virtual void test_entry_point(); \ }; \ template <typename F1, typename F2, typename F3, typename F4, typename F5> \ bool dispatch5(F1 &f1, F2 &f2, F3 &f3, F4 &f4, F5 *_f5_ptr_) { \ @@ -295,7 +295,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ size_t num_threads(threads); (void) num_threads; \ return dispatch2(f1, new fixture2); \ } \ - bool run() override { \ + virtual bool run() { \ TEST_STATE(name); \ size_t num_threads(threads); (void) num_threads; \ return dispatch1(new fixture1); \ @@ -332,7 +332,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ F5 &f5; \ F6 &f6; \ Test(F1 &f1_in, F2 &f2_in, F3 &f3_in, F4 &f4_in, F5 &f5_in, F6 &f6_in) : f1(f1_in), f2(f2_in), f3(f3_in), f4(f4_in), f5(f5_in), f6(f6_in) {} \ - void test_entry_point() override; \ + virtual void test_entry_point(); \ }; \ template <typename F1, typename F2, typename F3, typename F4, typename F5, typename F6> \ bool dispatch6(F1 &f1, F2 &f2, F3 &f3, F4 &f4, F5 &f5, F6 *_f6_ptr_) { \ @@ -465,7 +465,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ size_t num_threads(threads); (void) num_threads; \ return dispatch2(f1, new fixture2); \ } \ - bool run() override { \ + virtual bool run() { \ TEST_STATE(name); \ size_t num_threads(threads); (void) num_threads; \ return dispatch1(new fixture1); \ @@ -504,7 +504,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ F7 &f7; \ F8 &f8; \ Test(F1 &f1_in, F2 &f2_in, F3 &f3_in, F4 &f4_in, F5 &f5_in, F6 &f6_in, F7 &f7_in, F8 &f8_in) : f1(f1_in), f2(f2_in), f3(f3_in), f4(f4_in), f5(f5_in), f6(f6_in), f7(f7_in), f8(f8_in) {} \ - void test_entry_point() override; \ + virtual void test_entry_point(); \ }; \ template <typename F1, typename F2, typename F3, typename F4, typename F5, typename F6, typename F7, typename F8> \ bool dispatch8(F1 &f1, F2 &f2, F3 &f3, F4 &f4, F5 &f5, F6 &f6, F7 &f7, F8 *_f8_ptr_) { \ @@ -562,7 +562,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ size_t num_threads(threads); (void) num_threads; \ return dispatch2(f1, new fixture2); \ } \ - bool run() override { \ + virtual bool run() { \ TEST_STATE(name); \ size_t num_threads(threads); (void) num_threads; \ return dispatch1(new fixture1); \ @@ -602,7 +602,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ F8 &f8; \ F9 &f9; \ Test(F1 &f1_in, F2 &f2_in, F3 &f3_in, F4 &f4_in, F5 &f5_in, F6 &f6_in, F7 &f7_in, F8 &f8_in, F9 &f9_in) : f1(f1_in), f2(f2_in), f3(f3_in), f4(f4_in), f5(f5_in), f6(f6_in), f7(f7_in), f8(f8_in), f9(f9_in) {} \ - void test_entry_point() override; \ + virtual void test_entry_point(); \ }; \ template <typename F1, typename F2, typename F3, typename F4, typename F5, typename F6, typename F7, typename F8, typename F9> \ bool dispatch9(F1 &f1, F2 &f2, F3 &f3, F4 &f4, F5 &f5, F6 &f6, F7 &f7, F8 &f8, F9 *_f9_ptr_) { \ @@ -667,7 +667,7 @@ struct TEST_CAT(TestKitHook, __LINE__) : vespalib::TestHook { \ size_t num_threads(threads); (void) num_threads; \ return dispatch2(f1, new fixture2); \ } \ - bool run() override { \ + virtual bool run() { \ TEST_STATE(name); \ size_t num_threads(threads); (void) num_threads; \ return dispatch1(new fixture1); \ diff --git a/vespalib/src/vespa/vespalib/testkit/test_macros.h b/vespalib/src/vespa/vespalib/testkit/test_macros.h index 27244c07372..f0a33d5f15c 100644 --- a/vespalib/src/vespa/vespalib/testkit/test_macros.h +++ b/vespalib/src/vespa/vespalib/testkit/test_macros.h @@ -20,8 +20,8 @@ void test_kit_main(); \ struct TestKitApp : FastOS_Application \ { \ - bool useProcessStarter() const override { return useProxy; } \ - int Main() override; \ + virtual bool useProcessStarter() const { return useProxy; } \ + virtual int Main(); \ }; \ int main(int argc, char **argv) \ { \ diff --git a/vespalib/src/vespa/vespalib/testkit/testapp.h b/vespalib/src/vespa/vespalib/testkit/testapp.h index 7e3795dbf34..39b2cbcaa0b 100644 --- a/vespalib/src/vespa/vespalib/testkit/testapp.h +++ b/vespalib/src/vespa/vespalib/testkit/testapp.h @@ -19,7 +19,7 @@ #define TEST_SETUP(test) \ class test : public vespalib::TestApp \ { \ - public: int Main() override; \ + public: int Main(); \ }; \ TEST_APPHOOK(test) #define TEST_SETUP_WITHPROCESSPROXY(test) \ diff --git a/vespalib/src/vespa/vespalib/util/CMakeLists.txt b/vespalib/src/vespa/vespalib/util/CMakeLists.txt index 56a2ddb9f4e..fb6634b13f2 100644 --- a/vespalib/src/vespa/vespalib/util/CMakeLists.txt +++ b/vespalib/src/vespa/vespalib/util/CMakeLists.txt @@ -13,7 +13,6 @@ vespa_add_library(vespalib_vespalib_util OBJECT blockingthreadstackexecutor.cpp box.cpp classname.cpp - closuretask.cpp compress.cpp dual_merge_director.cpp error.cpp diff --git a/vespalib/src/vespa/vespalib/util/alloc.h b/vespalib/src/vespa/vespalib/util/alloc.h index e22289ade6f..120e63b95d3 100644 --- a/vespalib/src/vespa/vespalib/util/alloc.h +++ b/vespalib/src/vespa/vespalib/util/alloc.h @@ -12,7 +12,7 @@ namespace alloc { class MemoryAllocator { public: - enum {HUGEPAGE_SIZE=0x200000u}; + enum {HUGEPAGE_SIZE=0x200000}; using UP = std::unique_ptr<MemoryAllocator>; using PtrAndSize = std::pair<void *, size_t>; MemoryAllocator(const MemoryAllocator &) = delete; diff --git a/vespalib/src/vespa/vespalib/util/closure.h b/vespalib/src/vespa/vespalib/util/closure.h index a494c8d97df..81ea8430609 100644 --- a/vespalib/src/vespa/vespalib/util/closure.h +++ b/vespalib/src/vespa/vespalib/util/closure.h @@ -102,7 +102,9 @@ class Closure0_2 : public Closure0<R> { T1 _arg1; T2 _arg2; - R call() override { return _func(std::move(_arg1), std::move(_arg2)); } + virtual R call() override + { return _func(std::move(_arg1), std::move(_arg2)); } + public: Closure0_2(Func func, T1 &&arg1, T2 &&arg2) : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)) {} @@ -118,7 +120,8 @@ class Closure0_3 : public Closure0<R> { T2 _arg2; T3 _arg3; - R call() override { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3)); } + virtual R call() override + { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3)); } public: Closure0_3(Func func, T1 &&arg1, T2 &&arg2, T3 &&arg3) diff --git a/vespalib/src/vespa/vespalib/util/closuretask.cpp b/vespalib/src/vespa/vespalib/util/closuretask.cpp deleted file mode 100644 index bd1d5cebeed..00000000000 --- a/vespalib/src/vespa/vespalib/util/closuretask.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "closuretask.h" - -namespace vespalib { - -ClosureTask::~ClosureTask() {} - -Executor::Task::UP makeTask(std::unique_ptr<Closure> closure) { - return Executor::Task::UP(new ClosureTask(std::move(closure))); -} - -} diff --git a/vespalib/src/vespa/vespalib/util/closuretask.h b/vespalib/src/vespa/vespalib/util/closuretask.h index 233345403c3..8152897d447 100644 --- a/vespalib/src/vespa/vespalib/util/closuretask.h +++ b/vespalib/src/vespa/vespalib/util/closuretask.h @@ -15,14 +15,15 @@ class ClosureTask : public Executor::Task { public: ClosureTask(std::unique_ptr<Closure> closure) : _closure(std::move(closure)) {} - ~ClosureTask(); void run() override { _closure->call(); } }; /** * Wraps a Closure as an Executor::Task. **/ -Executor::Task::UP makeTask(std::unique_ptr<Closure> closure); +static inline Executor::Task::UP makeTask(std::unique_ptr<Closure> closure) { + return Executor::Task::UP(new ClosureTask(std::move(closure))); +} } // namespace vespalib diff --git a/vespalib/src/vespa/vespalib/util/dual_merge_director.cpp b/vespalib/src/vespa/vespalib/util/dual_merge_director.cpp index 02ccb5a1726..2e77ab3a09e 100644 --- a/vespalib/src/vespa/vespalib/util/dual_merge_director.cpp +++ b/vespalib/src/vespa/vespalib/util/dual_merge_director.cpp @@ -1,6 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "dual_merge_director.h" +#include <algorithm> namespace vespalib { @@ -41,8 +42,6 @@ DualMergeDirector::DualMergeDirector(size_t num_threads) { } -DualMergeDirector::~DualMergeDirector() {} - void DualMergeDirector::dualMerge(size_t thread_id, Source &typeA, Source &typeB) { diff --git a/vespalib/src/vespa/vespalib/util/dual_merge_director.h b/vespalib/src/vespa/vespalib/util/dual_merge_director.h index 3ccac4e9bf9..6676d40042e 100644 --- a/vespalib/src/vespa/vespalib/util/dual_merge_director.h +++ b/vespalib/src/vespa/vespalib/util/dual_merge_director.h @@ -67,7 +67,6 @@ private: public: DualMergeDirector(size_t num_threads); - ~DualMergeDirector(); void dualMerge(size_t thread_id, Source &typeA, Source &typeB); }; diff --git a/vespalib/src/vespa/vespalib/util/exception.cpp b/vespalib/src/vespa/vespalib/util/exception.cpp index 72a0fe8d99e..359bca2148f 100644 --- a/vespalib/src/vespa/vespalib/util/exception.cpp +++ b/vespalib/src/vespa/vespalib/util/exception.cpp @@ -1,6 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "exception.h" +#include <vespa/vespalib/util/exception.h> +#include <algorithm> +#include <vespa/fastos/backtrace.h> #ifdef VESPALIB_EXCEPTION_USEBACKTRACES #include <vespa/vespalib/util/backtrace.h> @@ -13,16 +15,19 @@ ExceptionPtr::ExceptionPtr() { } + ExceptionPtr::ExceptionPtr(const Exception &e) : _ref(e.clone()) { } + ExceptionPtr::ExceptionPtr(const ExceptionPtr &rhs) : _ref(rhs._ref != NULL ? rhs._ref->clone() : NULL) { } + ExceptionPtr & ExceptionPtr::operator=(const Exception &rhs) { @@ -31,6 +36,7 @@ ExceptionPtr::operator=(const Exception &rhs) return *this; } + ExceptionPtr & ExceptionPtr::operator=(const ExceptionPtr &rhs) { @@ -39,17 +45,20 @@ ExceptionPtr::operator=(const ExceptionPtr &rhs) return *this; } + void ExceptionPtr::swap(ExceptionPtr &other) { std::swap(_ref, other._ref); } + ExceptionPtr::~ExceptionPtr() { delete _ref; } + void swap(ExceptionPtr &a, ExceptionPtr &b) { @@ -77,11 +86,8 @@ Exception::Exception(const stringref &msg, const Exception &cause, _stackframes(getStackTraceFrames(_stack, STACK_FRAME_BUFFER_SIZE)), _skipStack(skipStack), _cause(cause) -{} - -Exception::Exception(const Exception &) = default; -Exception & Exception::operator = (const Exception &) = default; -Exception::~Exception() {} +{ +} const char * Exception::what() const throw() @@ -98,24 +104,33 @@ Exception::what() const throw() return _what.c_str(); } + const char * Exception::getName() const { return "Exception"; } + Exception * Exception::clone() const { return new Exception(*this); } + void Exception::throwSelf() const { throw Exception(*this); } + +Exception::~Exception() throw() +{ +} + + string Exception::toString() const { diff --git a/vespalib/src/vespa/vespalib/util/exception.h b/vespalib/src/vespa/vespalib/util/exception.h index 44911ea5555..af2f1bc225a 100644 --- a/vespalib/src/vespa/vespalib/util/exception.h +++ b/vespalib/src/vespa/vespalib/util/exception.h @@ -6,6 +6,7 @@ #include <vespa/vespalib/util/macro.h> #include <vespa/vespalib/util/error.h> #include <vespa/vespalib/util/stringfmt.h> +#include <string> #include <exception> #define VESPALIB_EXCEPTION_USEBACKTRACES @@ -188,7 +189,8 @@ public: * should send (skipStack + 1) to the parent constructor (see * \ref VESPA_DEFINE_EXCEPTION for subclass implementation). **/ - Exception(const stringref &msg, const stringref& location = "", int skipStack = 0); + Exception(const stringref &msg, const stringref& location = "", + int skipStack = 0); /** * @brief Construct an exception with a message, a causing exception, and a source code location. * @param msg A user-readable message describing the problem @@ -202,12 +204,6 @@ public: **/ Exception(const stringref &msg, const Exception &cause, const stringref &location = "", int skipStack = 0); - Exception(const Exception &); - Exception & operator = (const Exception &); - Exception(Exception &&) = default; - Exception & operator = (Exception &&) = default; - virtual ~Exception(); - /** @brief Returns a string describing the current exception, including cause if any */ const char *what() const throw() override; // should not be overridden @@ -230,6 +226,9 @@ public: /** @brief Throw a copy of this object */ virtual void throwSelf() const; + /** @brief destructor doing cleanup if needed */ + virtual ~Exception() throw(); + /** @brief make a string describing the current object, not including cause */ virtual string toString() const; }; diff --git a/vespalib/src/vespa/vespalib/util/exceptions.cpp b/vespalib/src/vespa/vespalib/util/exceptions.cpp index 2a551061b31..0520556aa60 100644 --- a/vespalib/src/vespa/vespalib/util/exceptions.cpp +++ b/vespalib/src/vespa/vespalib/util/exceptions.cpp @@ -43,18 +43,6 @@ ExceptionWithPayload::what() const noexcept { return _msg.c_str(); } -ExceptionWithPayload::ExceptionWithPayload(vespalib::stringref msg) - : std::exception(), - _msg(msg), - _payload() -{ } -ExceptionWithPayload::ExceptionWithPayload(vespalib::stringref msg, Anything::UP payload) - : std::exception(), - _msg(msg), - _payload(std::move(payload)) -{ } -ExceptionWithPayload::~ExceptionWithPayload() {} - SilenceUncaughtException::SilenceUncaughtException(const std::exception & e) : _oldTerminate(std::set_terminate(silent_terminate)) { @@ -96,11 +84,6 @@ PortListenException::PortListenException(int port, const vespalib::stringref &pr { } -PortListenException::PortListenException(const PortListenException &) = default; -PortListenException & PortListenException::operator = (const PortListenException &) = default; - -PortListenException::~PortListenException() {} - //----------------------------------------------------------------------------- IoException::IoException(const stringref & msg, Type type, diff --git a/vespalib/src/vespa/vespalib/util/exceptions.h b/vespalib/src/vespa/vespalib/util/exceptions.h index 65d17baf654..0fc0e96e193 100644 --- a/vespalib/src/vespa/vespalib/util/exceptions.h +++ b/vespalib/src/vespa/vespalib/util/exceptions.h @@ -68,11 +68,8 @@ public: using UP = std::unique_ptr<Anything>; virtual ~Anything() { } }; - ExceptionWithPayload(vespalib::stringref msg); - ExceptionWithPayload(vespalib::stringref msg, Anything::UP payload); - ExceptionWithPayload(ExceptionWithPayload &&) = default; - ExceptionWithPayload & operator = (ExceptionWithPayload &&) = default; - ~ExceptionWithPayload(); + ExceptionWithPayload(vespalib::stringref msg) : std::exception(), _msg(msg), _payload() { } + ExceptionWithPayload(vespalib::stringref msg, Anything::UP payload) : std::exception(), _msg(msg), _payload(std::move(payload)) { } void setPayload(Anything::UP payload) { _payload = std::move(payload); } const char * what() const noexcept override; private: @@ -107,11 +104,6 @@ public: const Exception &cause, const vespalib::stringref &msg = "", const vespalib::stringref &location = "", int skipStack = 0); - PortListenException(PortListenException &&) = default; - PortListenException & operator = (PortListenException &&) = default; - PortListenException(const PortListenException &); - PortListenException & operator = (const PortListenException &); - ~PortListenException(); VESPA_DEFINE_EXCEPTION_SPINE(PortListenException); int get_port() const { return _port; } const vespalib::string &get_protocol() const { return _protocol; } diff --git a/vespalib/src/vespa/vespalib/util/hashmap.h b/vespalib/src/vespa/vespalib/util/hashmap.h index f357ab6cf04..e97a77ea606 100644 --- a/vespalib/src/vespa/vespalib/util/hashmap.h +++ b/vespalib/src/vespa/vespalib/util/hashmap.h @@ -70,7 +70,7 @@ private: HashMap<T>& operator=(const HashMap<T> &); inline uint32_t getSize(uint32_t minBuckets) const; - Entry *lookup(const char *key) const; + inline Entry *lookup(const char *key) const; public: /** @@ -100,14 +100,14 @@ public: friend class Iterator; - explicit HashMap(const T &empty, uint32_t minBuckets = 50); - ~HashMap(); + inline explicit HashMap(const T &empty, uint32_t minBuckets = 50); + inline ~HashMap(); - void clear(); - T set(const char *key, const T &value); + inline void clear(); + inline T set(const char *key, const T &value); inline bool isSet(const char *key) const; inline const T &get(const char *key) const; - T remove(const char *key); + inline T remove(const char *key); inline const T& operator[](const char *key) const; // R-value inline Iterator iterator() const; diff --git a/vespalib/src/vespa/vespalib/util/left_right_heap.h b/vespalib/src/vespa/vespalib/util/left_right_heap.h index 94f5cc791ec..d2f11c4686b 100644 --- a/vespalib/src/vespa/vespalib/util/left_right_heap.h +++ b/vespalib/src/vespa/vespalib/util/left_right_heap.h @@ -54,7 +54,7 @@ struct RightHeap { struct LeftArrayHeap { static void require_left_heap() {} // for compile-time checks template <typename T> static T &front(T *, T *end) { return *(end - 1); } - template <typename T, typename C> static void push(T *begin, T *end, C cmp); + template <typename T, typename C> inline static void push(T *begin, T *end, C cmp); template <typename T, typename C> static void pop(T *, T *, C) {} template <typename T, typename C> inline static void adjust(T *begin, T *end, C cmp) { push(begin, end, cmp); @@ -69,7 +69,7 @@ struct LeftArrayHeap { struct RightArrayHeap { static void require_right_heap() {} // for compile-time checks template <typename T> static T &front(T *begin, T *) { return *begin; } - template <typename T, typename C> static void push(T *begin, T *end, C cmp); + template <typename T, typename C> inline static void push(T *begin, T *end, C cmp); template <typename T, typename C> static void pop(T *, T *, C) {} template <typename T, typename C> inline static void adjust(T *begin, T *end, C cmp) { push(begin, end, cmp); @@ -84,11 +84,12 @@ struct RightArrayHeap { struct LeftStdHeap { static void require_left_heap() {} // for compile-time checks template <typename T> static T &front(T *begin, T *) { return *begin; } - template <typename T, typename C> static void push(T *begin, T *end, C cmp); + template <typename T, typename C> inline static void push(T *begin, T *end, C cmp); template <typename T, typename C> static void pop(T *begin, T *end, C cmp); - template <typename T, typename C> static void adjust(T *begin, T *end, C cmp); + template <typename T, typename C> inline static void adjust(T *begin, T *end, C cmp); }; } // namespace vespalib #include "left_right_heap.hpp" + diff --git a/vespalib/src/vespa/vespalib/websocket/websocket_server.cpp b/vespalib/src/vespa/vespalib/websocket/websocket_server.cpp index 138812d542f..101a3a56884 100644 --- a/vespalib/src/vespa/vespalib/websocket/websocket_server.cpp +++ b/vespalib/src/vespa/vespalib/websocket/websocket_server.cpp @@ -1,9 +1,11 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <vespa/fastos/fastos.h> #include "websocket_server.h" #include "connection.h" #include "request.h" #include "key.h" +#include "frame.h" #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/util/host_name.h> @@ -116,8 +118,6 @@ void handle_upgrade(Connection &conn, Request &req) { } // namespace vespalib::ws::<unnamed> -WebsocketServer::StaticPage::~StaticPage() {} - WebsocketServer::WebsocketServer(int port_in, StaticRepo &&repo) : _acceptor(port_in, *this), _static_repo(std::move(repo)), @@ -125,8 +125,6 @@ WebsocketServer::WebsocketServer(int port_in, StaticRepo &&repo) { } -WebsocketServer::~WebsocketServer() {} - void WebsocketServer::handle(std::unique_ptr<Socket> socket) { diff --git a/vespalib/src/vespa/vespalib/websocket/websocket_server.h b/vespalib/src/vespa/vespalib/websocket/websocket_server.h index d711fe10985..3b36a7bd12e 100644 --- a/vespalib/src/vespa/vespalib/websocket/websocket_server.h +++ b/vespalib/src/vespa/vespalib/websocket/websocket_server.h @@ -4,8 +4,8 @@ #include "handler.h" #include "acceptor.h" -#include <vespa/vespalib/stllike/string.h> #include <map> +#include <vespa/vespalib/stllike/string.h> namespace vespalib { namespace ws { @@ -13,23 +13,19 @@ namespace ws { class WebsocketServer : public Handler<Socket> { public: struct StaticPage { - StaticPage(StaticPage &&) = default; - StaticPage & operator = (StaticPage &&) = default; - ~StaticPage(); vespalib::string content_type; vespalib::string content; }; typedef std::map<vespalib::string, StaticPage> StaticRepo; private: - Acceptor _acceptor; - StaticRepo _static_repo; + Acceptor _acceptor; + StaticRepo _static_repo; vespalib::string _self; public: WebsocketServer(int port_in, StaticRepo &&repo = StaticRepo()); - ~WebsocketServer(); - void handle(std::unique_ptr<Socket> socket) override; + virtual void handle(std::unique_ptr<Socket> socket) override; int port() { return _acceptor.port(); } }; |