diff options
author | Max Kellermann <max@musicpd.org> | 2017-11-10 20:20:07 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-11-10 20:20:07 +0100 |
commit | 59a88369243ee74a28c38054c85e779883b6e32f (patch) | |
tree | c65460fc099739ec2d710dcf81680651b225772a /src/event | |
parent | 9d4020501c622b52d26a1d0537ad867755476853 (diff) |
event/SocketMonitor: add "noexcept"
Diffstat (limited to 'src/event')
-rw-r--r-- | src/event/BufferedSocket.cxx | 2 | ||||
-rw-r--r-- | src/event/BufferedSocket.hxx | 3 | ||||
-rw-r--r-- | src/event/FullyBufferedSocket.cxx | 2 | ||||
-rw-r--r-- | src/event/FullyBufferedSocket.hxx | 4 | ||||
-rw-r--r-- | src/event/Loop.cxx | 2 | ||||
-rw-r--r-- | src/event/Loop.hxx | 2 | ||||
-rw-r--r-- | src/event/MultiSocketMonitor.hxx | 2 | ||||
-rw-r--r-- | src/event/ServerSocket.cxx | 4 | ||||
-rw-r--r-- | src/event/SignalMonitor.cxx | 4 | ||||
-rw-r--r-- | src/event/SocketMonitor.cxx | 18 | ||||
-rw-r--r-- | src/event/SocketMonitor.hxx | 42 |
11 files changed, 44 insertions, 41 deletions
diff --git a/src/event/BufferedSocket.cxx b/src/event/BufferedSocket.cxx index b13e9fded..d435ecaab 100644 --- a/src/event/BufferedSocket.cxx +++ b/src/event/BufferedSocket.cxx @@ -99,7 +99,7 @@ BufferedSocket::ResumeInput() } bool -BufferedSocket::OnSocketReady(unsigned flags) +BufferedSocket::OnSocketReady(unsigned flags) noexcept { assert(IsDefined()); diff --git a/src/event/BufferedSocket.hxx b/src/event/BufferedSocket.hxx index 849229960..4c286406f 100644 --- a/src/event/BufferedSocket.hxx +++ b/src/event/BufferedSocket.hxx @@ -113,7 +113,8 @@ protected: virtual void OnSocketError(std::exception_ptr ep) = 0; virtual void OnSocketClosed() = 0; - virtual bool OnSocketReady(unsigned flags) override; + /* virtual methods from class SocketMonitor */ + bool OnSocketReady(unsigned flags) noexcept override; }; #endif diff --git a/src/event/FullyBufferedSocket.cxx b/src/event/FullyBufferedSocket.cxx index d11be29bd..6e1b1106b 100644 --- a/src/event/FullyBufferedSocket.cxx +++ b/src/event/FullyBufferedSocket.cxx @@ -93,7 +93,7 @@ FullyBufferedSocket::Write(const void *data, size_t length) } bool -FullyBufferedSocket::OnSocketReady(unsigned flags) +FullyBufferedSocket::OnSocketReady(unsigned flags) noexcept { if (flags & WRITE) { assert(!output.empty()); diff --git a/src/event/FullyBufferedSocket.hxx b/src/event/FullyBufferedSocket.hxx index 71fcb0c36..c7ed93465 100644 --- a/src/event/FullyBufferedSocket.hxx +++ b/src/event/FullyBufferedSocket.hxx @@ -61,7 +61,9 @@ protected: */ bool Write(const void *data, size_t length); - virtual bool OnSocketReady(unsigned flags) override; + /* virtual methods from class SocketMonitor */ + bool OnSocketReady(unsigned flags) noexcept override; + virtual void OnIdle() override; }; diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx index e3ea891c4..92033e598 100644 --- a/src/event/Loop.cxx +++ b/src/event/Loop.cxx @@ -256,7 +256,7 @@ EventLoop::HandleDeferred() } bool -EventLoop::OnSocketReady(gcc_unused unsigned flags) +EventLoop::OnSocketReady(gcc_unused unsigned flags) noexcept { assert(IsInside()); diff --git a/src/event/Loop.hxx b/src/event/Loop.hxx index b76f4a762..eb8131609 100644 --- a/src/event/Loop.hxx +++ b/src/event/Loop.hxx @@ -188,7 +188,7 @@ private: */ void HandleDeferred(); - virtual bool OnSocketReady(unsigned flags) override; + bool OnSocketReady(unsigned flags) noexcept override; public: diff --git a/src/event/MultiSocketMonitor.hxx b/src/event/MultiSocketMonitor.hxx index fdf353bcc..ed83f1817 100644 --- a/src/event/MultiSocketMonitor.hxx +++ b/src/event/MultiSocketMonitor.hxx @@ -80,7 +80,7 @@ class MultiSocketMonitor : IdleMonitor } protected: - virtual bool OnSocketReady(unsigned flags) override { + bool OnSocketReady(unsigned flags) noexcept override { revents = flags; multi.SetReady(); return true; diff --git a/src/event/ServerSocket.cxx b/src/event/ServerSocket.cxx index 667b6846b..40329038b 100644 --- a/src/event/ServerSocket.cxx +++ b/src/event/ServerSocket.cxx @@ -115,7 +115,7 @@ public: void Accept() noexcept; private: - virtual bool OnSocketReady(unsigned flags) override; + bool OnSocketReady(unsigned flags) noexcept override; }; static constexpr Domain server_socket_domain("server_socket"); @@ -169,7 +169,7 @@ OneServerSocket::Accept() noexcept } bool -OneServerSocket::OnSocketReady(gcc_unused unsigned flags) +OneServerSocket::OnSocketReady(gcc_unused unsigned flags) noexcept { Accept(); return true; diff --git a/src/event/SignalMonitor.cxx b/src/event/SignalMonitor.cxx index b3ef41ecc..36c00b450 100644 --- a/src/event/SignalMonitor.cxx +++ b/src/event/SignalMonitor.cxx @@ -81,7 +81,7 @@ public: #endif private: - virtual bool OnSocketReady(unsigned flags) override; + bool OnSocketReady(unsigned flags) noexcept override; }; /* this should be enough - is it? */ @@ -197,7 +197,7 @@ SignalMonitorRegister(int signo, SignalHandler handler) } bool -SignalMonitor::OnSocketReady(unsigned) +SignalMonitor::OnSocketReady(unsigned) noexcept { #ifdef USE_SIGNALFD int signo; diff --git a/src/event/SocketMonitor.cxx b/src/event/SocketMonitor.cxx index 52b554644..8479f12d0 100644 --- a/src/event/SocketMonitor.cxx +++ b/src/event/SocketMonitor.cxx @@ -30,7 +30,7 @@ #endif void -SocketMonitor::Dispatch(unsigned flags) +SocketMonitor::Dispatch(unsigned flags) noexcept { flags &= GetScheduledFlags(); @@ -38,14 +38,14 @@ SocketMonitor::Dispatch(unsigned flags) Cancel(); } -SocketMonitor::~SocketMonitor() +SocketMonitor::~SocketMonitor() noexcept { if (IsDefined()) Cancel(); } void -SocketMonitor::Open(SocketDescriptor _fd) +SocketMonitor::Open(SocketDescriptor _fd) noexcept { assert(!fd.IsDefined()); assert(_fd.IsDefined()); @@ -54,7 +54,7 @@ SocketMonitor::Open(SocketDescriptor _fd) } SocketDescriptor -SocketMonitor::Steal() +SocketMonitor::Steal() noexcept { assert(IsDefined()); @@ -64,7 +64,7 @@ SocketMonitor::Steal() } void -SocketMonitor::Abandon() +SocketMonitor::Abandon() noexcept { assert(IsDefined()); @@ -73,13 +73,13 @@ SocketMonitor::Abandon() } void -SocketMonitor::Close() +SocketMonitor::Close() noexcept { Steal().Close(); } void -SocketMonitor::Schedule(unsigned flags) +SocketMonitor::Schedule(unsigned flags) noexcept { assert(IsDefined()); @@ -97,7 +97,7 @@ SocketMonitor::Schedule(unsigned flags) } SocketMonitor::ssize_t -SocketMonitor::Read(void *data, size_t length) +SocketMonitor::Read(void *data, size_t length) noexcept { assert(IsDefined()); @@ -110,7 +110,7 @@ SocketMonitor::Read(void *data, size_t length) } SocketMonitor::ssize_t -SocketMonitor::Write(const void *data, size_t length) +SocketMonitor::Write(const void *data, size_t length) noexcept { assert(IsDefined()); diff --git a/src/event/SocketMonitor.hxx b/src/event/SocketMonitor.hxx index 913e7b7e2..3a944a838 100644 --- a/src/event/SocketMonitor.hxx +++ b/src/event/SocketMonitor.hxx @@ -61,82 +61,82 @@ public: typedef std::make_signed<size_t>::type ssize_t; - explicit SocketMonitor(EventLoop &_loop) + explicit SocketMonitor(EventLoop &_loop) noexcept :loop(_loop) {} - SocketMonitor(SocketDescriptor _fd, EventLoop &_loop) + SocketMonitor(SocketDescriptor _fd, EventLoop &_loop) noexcept :fd(_fd), loop(_loop) {} - ~SocketMonitor(); + ~SocketMonitor() noexcept; - EventLoop &GetEventLoop() { + EventLoop &GetEventLoop() noexcept { return loop; } - bool IsDefined() const { + bool IsDefined() const noexcept { return fd.IsDefined(); } - SocketDescriptor Get() const { + SocketDescriptor Get() const noexcept { assert(IsDefined()); return fd; } - void Open(SocketDescriptor _fd); + void Open(SocketDescriptor _fd) noexcept; /** * "Steal" the socket descriptor. This abandons the socket * and returns it. */ - SocketDescriptor Steal(); + SocketDescriptor Steal() noexcept; /** * Somebody has closed the socket. Unregister this object. */ - void Abandon(); + void Abandon() noexcept; - void Close(); + void Close() noexcept; - unsigned GetScheduledFlags() const { + unsigned GetScheduledFlags() const noexcept { assert(IsDefined()); return scheduled_flags; } - void Schedule(unsigned flags); + void Schedule(unsigned flags) noexcept; - void Cancel() { + void Cancel() noexcept { Schedule(0); } - void ScheduleRead() { + void ScheduleRead() noexcept { Schedule(GetScheduledFlags() | READ | HANGUP | ERROR); } - void ScheduleWrite() { + void ScheduleWrite() noexcept { Schedule(GetScheduledFlags() | WRITE); } - void CancelRead() { + void CancelRead() noexcept { Schedule(GetScheduledFlags() & ~(READ|HANGUP|ERROR)); } - void CancelWrite() { + void CancelWrite() noexcept { Schedule(GetScheduledFlags() & ~WRITE); } - ssize_t Read(void *data, size_t length); - ssize_t Write(const void *data, size_t length); + ssize_t Read(void *data, size_t length) noexcept; + ssize_t Write(const void *data, size_t length) noexcept; protected: /** * @return false if the socket has been closed */ - virtual bool OnSocketReady(unsigned flags) = 0; + virtual bool OnSocketReady(unsigned flags) noexcept = 0; public: - void Dispatch(unsigned flags); + void Dispatch(unsigned flags) noexcept; }; #endif |