diff options
Diffstat (limited to 'vespalib')
31 files changed, 191 insertions, 160 deletions
diff --git a/vespalib/src/tests/alloc/alloc_test.cpp b/vespalib/src/tests/alloc/alloc_test.cpp index 5da06091796..11372c0aebd 100644 --- a/vespalib/src/tests/alloc/alloc_test.cpp +++ b/vespalib/src/tests/alloc/alloc_test.cpp @@ -1,11 +1,9 @@ // 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; @@ -16,11 +14,11 @@ testSwap(T & a, T & b) { void * tmpA(a.get()); void * tmpB(b.get()); - EXPECT_EQUAL(4096u, a.size()); - EXPECT_EQUAL(8192, b.size()); + EXPECT_EQUAL(4096ul, a.size()); + EXPECT_EQUAL(8192ul, b.size()); std::swap(a, b); - EXPECT_EQUAL(4096u, b.size()); - EXPECT_EQUAL(8192, a.size()); + EXPECT_EQUAL(4096ul, b.size()); + EXPECT_EQUAL(8192ul, a.size()); EXPECT_EQUAL(tmpA, b.get()); EXPECT_EQUAL(tmpB, a.get()); } @@ -87,46 +85,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(MemoryAllocator::HUGEPAGE_SIZE*11+3, buf.size()); + EXPECT_EQUAL(size_t(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*2, buf.size()); + EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE*2ul, buf.size()); } TEST("rounding of large mmaped buffer") { Alloc buf = Alloc::alloc(MemoryAllocator::HUGEPAGE_SIZE*11+3); - EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE*12, buf.size()); + EXPECT_EQUAL(MemoryAllocator::HUGEPAGE_SIZE*12ul, buf.size()); } TEST("heap alloc can not be extended") { Alloc buf = Alloc::allocHeap(100); void * oldPtr = buf.get(); - EXPECT_EQUAL(100, buf.size()); + EXPECT_EQUAL(100ul, buf.size()); EXPECT_FALSE(buf.resize_inplace(101)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(100, buf.size()); + EXPECT_EQUAL(100ul, buf.size()); } TEST("auto alloced heap alloc can not be extended") { Alloc buf = Alloc::alloc(100); void * oldPtr = buf.get(); - EXPECT_EQUAL(100, buf.size()); + EXPECT_EQUAL(100ul, buf.size()); EXPECT_FALSE(buf.resize_inplace(101)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(100, buf.size()); + EXPECT_EQUAL(100ul, 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(100, buf.size()); + EXPECT_EQUAL(100ul, buf.size()); EXPECT_FALSE(buf.resize_inplace(MemoryAllocator::HUGEPAGE_SIZE*3)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(100, buf.size()); + EXPECT_EQUAL(100ul, buf.size()); } TEST("auto alloced mmap alloc can be extended if room") { @@ -183,10 +181,10 @@ TEST("mmap alloc can be extended if room") { } void * oldPtr = buf.get(); - EXPECT_EQUAL(4096, buf.size()); + EXPECT_EQUAL(4096ul, buf.size()); EXPECT_TRUE(buf.resize_inplace(4097)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(8192, buf.size()); + EXPECT_EQUAL(8192ul, buf.size()); } TEST("mmap alloc can not be extended if no room") { @@ -199,37 +197,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(4096, buf.size()); + EXPECT_EQUAL(4096ul, buf.size()); EXPECT_FALSE(buf.resize_inplace(4097)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(4096, buf.size()); + EXPECT_EQUAL(4096ul, buf.size()); } TEST("heap alloc can not be shrinked") { Alloc buf = Alloc::allocHeap(101); void * oldPtr = buf.get(); - EXPECT_EQUAL(101, buf.size()); + EXPECT_EQUAL(101ul, buf.size()); EXPECT_FALSE(buf.resize_inplace(100)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(101, buf.size()); + EXPECT_EQUAL(101ul, buf.size()); } TEST("mmap alloc can be shrinked") { Alloc buf = Alloc::allocMMap(4097); void * oldPtr = buf.get(); - EXPECT_EQUAL(8192, buf.size()); + EXPECT_EQUAL(8192ul, buf.size()); EXPECT_TRUE(buf.resize_inplace(4095)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(4096, buf.size()); + EXPECT_EQUAL(4096ul, buf.size()); } TEST("auto alloced heap alloc can not be shrinked") { Alloc buf = Alloc::alloc(101); void * oldPtr = buf.get(); - EXPECT_EQUAL(101, buf.size()); + EXPECT_EQUAL(101ul, buf.size()); EXPECT_FALSE(buf.resize_inplace(100)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(101, buf.size()); + EXPECT_EQUAL(101ul, 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 9ef127be364..444f57809f7 100644 --- a/vespalib/src/tests/data/input_reader/input_reader_test.cpp +++ b/vespalib/src/tests/data/input_reader/input_reader_test.cpp @@ -3,7 +3,6 @@ #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; @@ -92,12 +91,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(), 5); - EXPECT_EQUAL(src.obtain(), 5); + EXPECT_EQUAL(src.obtain(), 5u); + EXPECT_EQUAL(src.obtain(), 5u); EXPECT_EQUAL(src.read(5), Memory("12345")); EXPECT_TRUE(!src.failed()); - EXPECT_EQUAL(src.obtain(), 0); - EXPECT_EQUAL(src.obtain(), 0); + EXPECT_EQUAL(src.obtain(), 0u); + EXPECT_EQUAL(src.obtain(), 0u); EXPECT_TRUE(!src.failed()); if (byte_first) { EXPECT_EQUAL(src.read(), 0); @@ -109,7 +108,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(), 0); + EXPECT_EQUAL(src.obtain(), 0u); } } 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 a62283500f0..fa41961e22a 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, 10); + EXPECT_EQUAL(memory.size, 10u); 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 3d59b2fcb1e..72e3751b279 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, 200); + EXPECT_EQUAL(str_len, 200u); 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 55ef70d2d61..b4b0ce1e31f 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()), data.size()); + ASSERT_EQUAL(write(fd, data.data(), data.size()), ssize_t(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, server_message.size()); + EXPECT_EQUAL(written, ssize_t(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, client_message.size()); + EXPECT_EQUAL(written, ssize_t(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 931c612c1d3..3c6fabd8264 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 (size_t i = 0; i < 3; ++i) { + for (int 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(0, destruct); - EXPECT_EQUAL(0, destruct_nodelete); + EXPECT_EQUAL(0u, destruct); + EXPECT_EQUAL(0u, destruct_nodelete); } - EXPECT_EQUAL(5, destruct); - EXPECT_EQUAL(0, destruct_nodelete); + EXPECT_EQUAL(5u, destruct); + EXPECT_EQUAL(0u, 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 16c044a9902..54fa65daea6 100644 --- a/vespalib/src/tests/sync/sync_test.cpp +++ b/vespalib/src/tests/sync/sync_test.cpp @@ -18,10 +18,12 @@ 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 8e385b74eae..8bccf6c969d 100644 --- a/vespalib/src/vespa/vespalib/component/version.cpp +++ b/vespalib/src/vespa/vespalib/component/version.cpp @@ -3,7 +3,6 @@ #include "version.h" #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/stllike/asciistream.h> -#include <cctype> #include <climits> namespace vespalib { @@ -19,6 +18,8 @@ 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 58c680ce8f1..34e5bcc818c 100644 --- a/vespalib/src/vespa/vespalib/component/version.h +++ b/vespalib/src/vespa/vespalib/component/version.h @@ -60,6 +60,8 @@ 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 2b7460933cf..c9b1c4c37e5 100644 --- a/vespalib/src/vespa/vespalib/data/slime/binary_format.cpp +++ b/vespalib/src/vespa/vespalib/data/slime/binary_format.cpp @@ -1,9 +1,7 @@ // 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 { @@ -265,5 +263,27 @@ 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 df6e32a0b22..39fc3c5d688 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 <string> -#include <vespa/vespalib/data/output.h> #include "type.h" +#include "inserter.h" +#include <vespa/vespalib/data/output.h> #include <vespa/vespalib/data/input_reader.h> #include <vespa/vespalib/data/output_writer.h> -#include "inserter.h" +#include <string> namespace vespalib { @@ -55,9 +55,10 @@ inline uint32_t decode_meta(uint32_t type_and_meta) { return ((type_and_meta >> 3) & 0x1f); } -inline uint32_t encode_cmpr_ulong(char *out, - uint64_t value) -{ + +void write_cmpr_ulong(OutputWriter &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); @@ -71,14 +72,7 @@ inline uint32_t encode_cmpr_ulong(char *out, return (pos - out); } -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) -{ +inline uint64_t read_cmpr_ulong(InputReader &in) { uint64_t next = in.read(); uint64_t value = (next & 0x7f); int shift = 7; @@ -90,19 +84,7 @@ inline uint64_t read_cmpr_ulong(InputReader &in) return value; } -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); -} +void write_type_and_size(OutputWriter &out, uint32_t type, uint64_t size); inline uint64_t read_size(InputReader &in, uint32_t meta) { @@ -110,8 +92,8 @@ inline uint64_t read_size(InputReader &in, uint32_t meta) } template <bool top> -inline void write_type_and_bytes(OutputWriter &out, - uint32_t type, uint64_t bits) +void write_type_and_bytes(OutputWriter &out, + uint32_t type, uint64_t bits) { char *start = out.reserve(9); // max size char *pos = start + 1; @@ -129,8 +111,7 @@ inline void write_type_and_bytes(OutputWriter &out, } template <bool top> -inline uint64_t read_bytes(InputReader &in, - uint32_t bytes) +uint64_t read_bytes(InputReader &in, uint32_t bytes) { uint64_t value = 0; int shift = top ? 56 : 0; @@ -150,4 +131,3 @@ inline uint64_t read_bytes(InputReader &in, } // namespace vespalib::slime } // namespace vespalib - diff --git a/vespalib/src/vespa/vespalib/io/fileutil.cpp b/vespalib/src/vespa/vespalib/io/fileutil.cpp index 192dcf7c413..2794a519800 100644 --- a/vespalib/src/vespa/vespalib/io/fileutil.cpp +++ b/vespalib/src/vespa/vespalib/io/fileutil.cpp @@ -610,6 +610,11 @@ 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 8ad05c96152..3984ec796c8 100644 --- a/vespalib/src/vespa/vespalib/io/fileutil.h +++ b/vespalib/src/vespa/vespalib/io/fileutil.h @@ -28,7 +28,6 @@ #pragma once #include <unistd.h> -#include <string> #include <memory> #include <vector> #include <vespa/vespalib/stllike/string.h> @@ -319,9 +318,7 @@ extern FileInfo::UP lstat(const vespalib::stringref & path); * * @throw IoException If we failed to stat the file. */ -extern inline bool fileExists(const vespalib::stringref & path) { - return (stat(path).get() != 0); -} +extern bool fileExists(const vespalib::stringref & path); /** * Check if a path exists, i.e. whether it's a symbolic link, regular file, @@ -452,4 +449,3 @@ 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 438b8bbcdf0..94fc392bcdd 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 { \ - virtual void test_entry_point(); \ + void test_entry_point() override; \ }; \ - virtual bool run() { \ + bool run() override { \ 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) {} \ - virtual void test_entry_point(); \ + void test_entry_point() override; \ }; \ 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); \ } \ - virtual bool run() { \ + bool run() override { \ 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) {} \ - virtual void test_entry_point(); \ + void test_entry_point() override; \ }; \ 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); \ } \ - virtual bool run() { \ + bool run() override { \ 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) {} \ - virtual void test_entry_point(); \ + void test_entry_point() override; \ }; \ 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); \ } \ - virtual bool run() { \ + bool run() override { \ 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) {} \ - virtual void test_entry_point(); \ + void test_entry_point() override; \ }; \ 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); \ } \ - virtual bool run() { \ + bool run() override { \ 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) {} \ - virtual void test_entry_point(); \ + void test_entry_point() override; \ }; \ 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); \ } \ - virtual bool run() { \ + bool run() override { \ 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) {} \ - virtual void test_entry_point(); \ + void test_entry_point() override; \ }; \ 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); \ } \ - virtual bool run() { \ + bool run() override { \ 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) {} \ - virtual void test_entry_point(); \ + void test_entry_point() override; \ }; \ 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); \ } \ - virtual bool run() { \ + bool run() override { \ 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) {} \ - virtual void test_entry_point(); \ + void test_entry_point() override; \ }; \ 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); \ } \ - virtual bool run() { \ + bool run() override { \ 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 f0a33d5f15c..27244c07372 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 \ { \ - virtual bool useProcessStarter() const { return useProxy; } \ - virtual int Main(); \ + bool useProcessStarter() const override { return useProxy; } \ + int Main() override; \ }; \ 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 39b2cbcaa0b..7e3795dbf34 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(); \ + public: int Main() override; \ }; \ 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 fb6634b13f2..56a2ddb9f4e 100644 --- a/vespalib/src/vespa/vespalib/util/CMakeLists.txt +++ b/vespalib/src/vespa/vespalib/util/CMakeLists.txt @@ -13,6 +13,7 @@ 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 120e63b95d3..e22289ade6f 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=0x200000}; + enum {HUGEPAGE_SIZE=0x200000u}; 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 81ea8430609..a494c8d97df 100644 --- a/vespalib/src/vespa/vespalib/util/closure.h +++ b/vespalib/src/vespa/vespalib/util/closure.h @@ -102,9 +102,7 @@ class Closure0_2 : public Closure0<R> { T1 _arg1; T2 _arg2; - virtual R call() override - { return _func(std::move(_arg1), std::move(_arg2)); } - + 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)) {} @@ -120,8 +118,7 @@ class Closure0_3 : public Closure0<R> { T2 _arg2; T3 _arg3; - virtual R call() override - { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3)); } + 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 new file mode 100644 index 00000000000..bd1d5cebeed --- /dev/null +++ b/vespalib/src/vespa/vespalib/util/closuretask.cpp @@ -0,0 +1,13 @@ +// 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 8152897d447..233345403c3 100644 --- a/vespalib/src/vespa/vespalib/util/closuretask.h +++ b/vespalib/src/vespa/vespalib/util/closuretask.h @@ -15,15 +15,14 @@ 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. **/ -static inline Executor::Task::UP makeTask(std::unique_ptr<Closure> closure) { - return Executor::Task::UP(new ClosureTask(std::move(closure))); -} +Executor::Task::UP makeTask(std::unique_ptr<Closure> 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 2e77ab3a09e..02ccb5a1726 100644 --- a/vespalib/src/vespa/vespalib/util/dual_merge_director.cpp +++ b/vespalib/src/vespa/vespalib/util/dual_merge_director.cpp @@ -1,7 +1,6 @@ // 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 { @@ -42,6 +41,8 @@ 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 6676d40042e..3ccac4e9bf9 100644 --- a/vespalib/src/vespa/vespalib/util/dual_merge_director.h +++ b/vespalib/src/vespa/vespalib/util/dual_merge_director.h @@ -67,6 +67,7 @@ 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 359bca2148f..72a0fe8d99e 100644 --- a/vespalib/src/vespa/vespalib/util/exception.cpp +++ b/vespalib/src/vespa/vespalib/util/exception.cpp @@ -1,8 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/util/exception.h> -#include <algorithm> -#include <vespa/fastos/backtrace.h> +#include "exception.h" #ifdef VESPALIB_EXCEPTION_USEBACKTRACES #include <vespa/vespalib/util/backtrace.h> @@ -15,19 +13,16 @@ 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) { @@ -36,7 +31,6 @@ ExceptionPtr::operator=(const Exception &rhs) return *this; } - ExceptionPtr & ExceptionPtr::operator=(const ExceptionPtr &rhs) { @@ -45,20 +39,17 @@ 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) { @@ -86,8 +77,11 @@ 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() @@ -104,33 +98,24 @@ 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 af2f1bc225a..44911ea5555 100644 --- a/vespalib/src/vespa/vespalib/util/exception.h +++ b/vespalib/src/vespa/vespalib/util/exception.h @@ -6,7 +6,6 @@ #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 @@ -189,8 +188,7 @@ 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 @@ -204,6 +202,12 @@ 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 @@ -226,9 +230,6 @@ 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 0520556aa60..2a551061b31 100644 --- a/vespalib/src/vespa/vespalib/util/exceptions.cpp +++ b/vespalib/src/vespa/vespalib/util/exceptions.cpp @@ -43,6 +43,18 @@ 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)) { @@ -84,6 +96,11 @@ 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 0fc0e96e193..65d17baf654 100644 --- a/vespalib/src/vespa/vespalib/util/exceptions.h +++ b/vespalib/src/vespa/vespalib/util/exceptions.h @@ -68,8 +68,11 @@ public: using UP = std::unique_ptr<Anything>; virtual ~Anything() { } }; - ExceptionWithPayload(vespalib::stringref msg) : std::exception(), _msg(msg), _payload() { } - ExceptionWithPayload(vespalib::stringref msg, Anything::UP payload) : std::exception(), _msg(msg), _payload(std::move(payload)) { } + ExceptionWithPayload(vespalib::stringref msg); + ExceptionWithPayload(vespalib::stringref msg, Anything::UP payload); + ExceptionWithPayload(ExceptionWithPayload &&) = default; + ExceptionWithPayload & operator = (ExceptionWithPayload &&) = default; + ~ExceptionWithPayload(); void setPayload(Anything::UP payload) { _payload = std::move(payload); } const char * what() const noexcept override; private: @@ -104,6 +107,11 @@ 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 e97a77ea606..f357ab6cf04 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; - inline Entry *lookup(const char *key) const; + Entry *lookup(const char *key) const; public: /** @@ -100,14 +100,14 @@ public: friend class Iterator; - inline explicit HashMap(const T &empty, uint32_t minBuckets = 50); - inline ~HashMap(); + explicit HashMap(const T &empty, uint32_t minBuckets = 50); + ~HashMap(); - inline void clear(); - inline T set(const char *key, const T &value); + void clear(); + T set(const char *key, const T &value); inline bool isSet(const char *key) const; inline const T &get(const char *key) const; - inline T remove(const char *key); + 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 d2f11c4686b..94f5cc791ec 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> inline static void push(T *begin, T *end, C cmp); + template <typename T, typename C> 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> inline static void push(T *begin, T *end, C cmp); + template <typename T, typename C> 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,12 +84,11 @@ 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> inline static void push(T *begin, T *end, C cmp); + template <typename T, typename C> 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> inline static void adjust(T *begin, T *end, C cmp); + template <typename T, typename C> 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 101a3a56884..138812d542f 100644 --- a/vespalib/src/vespa/vespalib/websocket/websocket_server.cpp +++ b/vespalib/src/vespa/vespalib/websocket/websocket_server.cpp @@ -1,11 +1,9 @@ // 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> @@ -118,6 +116,8 @@ 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,6 +125,8 @@ 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 3b36a7bd12e..d711fe10985 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 <map> #include <vespa/vespalib/stllike/string.h> +#include <map> namespace vespalib { namespace ws { @@ -13,19 +13,23 @@ 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()); - virtual void handle(std::unique_ptr<Socket> socket) override; + ~WebsocketServer(); + void handle(std::unique_ptr<Socket> socket) override; int port() { return _acceptor.port(); } }; |