From cd6de3b24e463a47457b4aa8fad2d5257e8c44e7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 2 Jan 2018 16:58:14 +0100 Subject: [PATCH] neighbor/{Explorer,Listener}: add "noexcept" --- src/Instance.cxx | 4 ++-- src/Instance.hxx | 4 ++-- src/neighbor/Explorer.hxx | 4 ++-- src/neighbor/Glue.cxx | 6 +++--- src/neighbor/Glue.hxx | 12 +++++++----- src/neighbor/Listener.hxx | 4 ++-- test/run_neighbor_explorer.cxx | 4 ++-- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/Instance.cxx b/src/Instance.cxx index bd91faccd..bd5d377a9 100644 --- a/src/Instance.cxx +++ b/src/Instance.cxx @@ -98,14 +98,14 @@ Instance::OnDatabaseSongRemoved(const char *uri) #ifdef ENABLE_NEIGHBOR_PLUGINS void -Instance::FoundNeighbor(gcc_unused const NeighborInfo &info) +Instance::FoundNeighbor(gcc_unused const NeighborInfo &info) noexcept { for (auto &partition : partitions) partition.EmitIdle(IDLE_NEIGHBOR); } void -Instance::LostNeighbor(gcc_unused const NeighborInfo &info) +Instance::LostNeighbor(gcc_unused const NeighborInfo &info) noexcept { for (auto &partition : partitions) partition.EmitIdle(IDLE_NEIGHBOR); diff --git a/src/Instance.hxx b/src/Instance.hxx index 204b526a2..a3d0eb61f 100644 --- a/src/Instance.hxx +++ b/src/Instance.hxx @@ -139,8 +139,8 @@ private: #ifdef ENABLE_NEIGHBOR_PLUGINS /* virtual methods from class NeighborListener */ - void FoundNeighbor(const NeighborInfo &info) override; - void LostNeighbor(const NeighborInfo &info) override; + void FoundNeighbor(const NeighborInfo &info) noexcept override; + void LostNeighbor(const NeighborInfo &info) noexcept override; #endif /* callback for #idle_monitor */ diff --git a/src/neighbor/Explorer.hxx b/src/neighbor/Explorer.hxx index b62f04b1f..b0eaa0d6f 100644 --- a/src/neighbor/Explorer.hxx +++ b/src/neighbor/Explorer.hxx @@ -40,7 +40,7 @@ class NeighborExplorer { protected: NeighborListener &listener; - explicit NeighborExplorer(NeighborListener &_listener) + explicit NeighborExplorer(NeighborListener &_listener) noexcept :listener(_listener) {} public: @@ -49,7 +49,7 @@ public: /** * Free instance data. */ - virtual ~NeighborExplorer() {} + virtual ~NeighborExplorer() noexcept {} /** * Start exploring the neighborhood. diff --git a/src/neighbor/Glue.cxx b/src/neighbor/Glue.cxx index f82e47fb8..ad56acd94 100644 --- a/src/neighbor/Glue.cxx +++ b/src/neighbor/Glue.cxx @@ -30,12 +30,12 @@ #include -NeighborGlue::Explorer::~Explorer() +NeighborGlue::Explorer::~Explorer() noexcept { delete explorer; } -NeighborGlue::~NeighborGlue() {} +NeighborGlue::~NeighborGlue() noexcept {} static NeighborExplorer * CreateNeighborExplorer(EventLoop &loop, NeighborListener &listener, @@ -86,7 +86,7 @@ NeighborGlue::Open() } void -NeighborGlue::Close() +NeighborGlue::Close() noexcept { for (auto i = explorers.begin(), end = explorers.end(); i != end; ++i) i->explorer->Close(); diff --git a/src/neighbor/Glue.hxx b/src/neighbor/Glue.hxx index a0d749a3b..e4ca84bf3 100644 --- a/src/neighbor/Glue.hxx +++ b/src/neighbor/Glue.hxx @@ -38,9 +38,11 @@ class NeighborGlue { struct Explorer { NeighborExplorer *const explorer; - Explorer(NeighborExplorer *_explorer):explorer(_explorer) {} + Explorer(NeighborExplorer *_explorer) noexcept + :explorer(_explorer) {} + Explorer(const Explorer &) = delete; - ~Explorer(); + ~Explorer() noexcept; }; Mutex mutex; @@ -52,9 +54,9 @@ public: NeighborGlue() = default; NeighborGlue(const NeighborGlue &) = delete; - ~NeighborGlue(); + ~NeighborGlue() noexcept; - bool IsEmpty() const { + bool IsEmpty() const noexcept { return explorers.empty(); } @@ -64,7 +66,7 @@ public: void Init(EventLoop &loop, NeighborListener &listener); void Open(); - void Close(); + void Close() noexcept; /** * Get the combined list of all neighbors from all active diff --git a/src/neighbor/Listener.hxx b/src/neighbor/Listener.hxx index 089c69aad..d895a457e 100644 --- a/src/neighbor/Listener.hxx +++ b/src/neighbor/Listener.hxx @@ -29,8 +29,8 @@ class NeighborExplorer; */ class NeighborListener { public: - virtual void FoundNeighbor(const NeighborInfo &info) = 0; - virtual void LostNeighbor(const NeighborInfo &info) = 0; + virtual void FoundNeighbor(const NeighborInfo &info) noexcept = 0; + virtual void LostNeighbor(const NeighborInfo &info) noexcept = 0; }; #endif diff --git a/test/run_neighbor_explorer.cxx b/test/run_neighbor_explorer.cxx index f07f1af21..9e2d0436e 100644 --- a/test/run_neighbor_explorer.cxx +++ b/test/run_neighbor_explorer.cxx @@ -43,12 +43,12 @@ public: class MyNeighborListener final : public NeighborListener { public: /* virtual methods from class NeighborListener */ - virtual void FoundNeighbor(const NeighborInfo &info) override { + virtual void FoundNeighbor(const NeighborInfo &info) noexcept override { printf("found '%s' (%s)\n", info.display_name.c_str(), info.uri.c_str()); } - virtual void LostNeighbor(const NeighborInfo &info) override { + virtual void LostNeighbor(const NeighborInfo &info) noexcept override { printf("lost '%s' (%s)\n", info.display_name.c_str(), info.uri.c_str()); }