neighbor/{Explorer,Listener}: add "noexcept"

This commit is contained in:
Max Kellermann 2018-01-02 16:58:14 +01:00
parent dcd483bd99
commit cd6de3b24e
7 changed files with 20 additions and 18 deletions

View File

@ -98,14 +98,14 @@ Instance::OnDatabaseSongRemoved(const char *uri)
#ifdef ENABLE_NEIGHBOR_PLUGINS #ifdef ENABLE_NEIGHBOR_PLUGINS
void void
Instance::FoundNeighbor(gcc_unused const NeighborInfo &info) Instance::FoundNeighbor(gcc_unused const NeighborInfo &info) noexcept
{ {
for (auto &partition : partitions) for (auto &partition : partitions)
partition.EmitIdle(IDLE_NEIGHBOR); partition.EmitIdle(IDLE_NEIGHBOR);
} }
void void
Instance::LostNeighbor(gcc_unused const NeighborInfo &info) Instance::LostNeighbor(gcc_unused const NeighborInfo &info) noexcept
{ {
for (auto &partition : partitions) for (auto &partition : partitions)
partition.EmitIdle(IDLE_NEIGHBOR); partition.EmitIdle(IDLE_NEIGHBOR);

View File

@ -139,8 +139,8 @@ private:
#ifdef ENABLE_NEIGHBOR_PLUGINS #ifdef ENABLE_NEIGHBOR_PLUGINS
/* virtual methods from class NeighborListener */ /* virtual methods from class NeighborListener */
void FoundNeighbor(const NeighborInfo &info) override; void FoundNeighbor(const NeighborInfo &info) noexcept override;
void LostNeighbor(const NeighborInfo &info) override; void LostNeighbor(const NeighborInfo &info) noexcept override;
#endif #endif
/* callback for #idle_monitor */ /* callback for #idle_monitor */

View File

@ -40,7 +40,7 @@ class NeighborExplorer {
protected: protected:
NeighborListener &listener; NeighborListener &listener;
explicit NeighborExplorer(NeighborListener &_listener) explicit NeighborExplorer(NeighborListener &_listener) noexcept
:listener(_listener) {} :listener(_listener) {}
public: public:
@ -49,7 +49,7 @@ public:
/** /**
* Free instance data. * Free instance data.
*/ */
virtual ~NeighborExplorer() {} virtual ~NeighborExplorer() noexcept {}
/** /**
* Start exploring the neighborhood. * Start exploring the neighborhood.

View File

@ -30,12 +30,12 @@
#include <stdexcept> #include <stdexcept>
NeighborGlue::Explorer::~Explorer() NeighborGlue::Explorer::~Explorer() noexcept
{ {
delete explorer; delete explorer;
} }
NeighborGlue::~NeighborGlue() {} NeighborGlue::~NeighborGlue() noexcept {}
static NeighborExplorer * static NeighborExplorer *
CreateNeighborExplorer(EventLoop &loop, NeighborListener &listener, CreateNeighborExplorer(EventLoop &loop, NeighborListener &listener,
@ -86,7 +86,7 @@ NeighborGlue::Open()
} }
void void
NeighborGlue::Close() NeighborGlue::Close() noexcept
{ {
for (auto i = explorers.begin(), end = explorers.end(); i != end; ++i) for (auto i = explorers.begin(), end = explorers.end(); i != end; ++i)
i->explorer->Close(); i->explorer->Close();

View File

@ -38,9 +38,11 @@ class NeighborGlue {
struct Explorer { struct Explorer {
NeighborExplorer *const explorer; NeighborExplorer *const explorer;
Explorer(NeighborExplorer *_explorer):explorer(_explorer) {} Explorer(NeighborExplorer *_explorer) noexcept
:explorer(_explorer) {}
Explorer(const Explorer &) = delete; Explorer(const Explorer &) = delete;
~Explorer(); ~Explorer() noexcept;
}; };
Mutex mutex; Mutex mutex;
@ -52,9 +54,9 @@ public:
NeighborGlue() = default; NeighborGlue() = default;
NeighborGlue(const NeighborGlue &) = delete; NeighborGlue(const NeighborGlue &) = delete;
~NeighborGlue(); ~NeighborGlue() noexcept;
bool IsEmpty() const { bool IsEmpty() const noexcept {
return explorers.empty(); return explorers.empty();
} }
@ -64,7 +66,7 @@ public:
void Init(EventLoop &loop, NeighborListener &listener); void Init(EventLoop &loop, NeighborListener &listener);
void Open(); void Open();
void Close(); void Close() noexcept;
/** /**
* Get the combined list of all neighbors from all active * Get the combined list of all neighbors from all active

View File

@ -29,8 +29,8 @@ class NeighborExplorer;
*/ */
class NeighborListener { class NeighborListener {
public: public:
virtual void FoundNeighbor(const NeighborInfo &info) = 0; virtual void FoundNeighbor(const NeighborInfo &info) noexcept = 0;
virtual void LostNeighbor(const NeighborInfo &info) = 0; virtual void LostNeighbor(const NeighborInfo &info) noexcept = 0;
}; };
#endif #endif

View File

@ -43,12 +43,12 @@ public:
class MyNeighborListener final : public NeighborListener { class MyNeighborListener final : public NeighborListener {
public: public:
/* virtual methods from class NeighborListener */ /* 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", printf("found '%s' (%s)\n",
info.display_name.c_str(), info.uri.c_str()); 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", printf("lost '%s' (%s)\n",
info.display_name.c_str(), info.uri.c_str()); info.display_name.c_str(), info.uri.c_str());
} }