diff options
author | Max Kellermann <max@musicpd.org> | 2021-02-22 14:26:18 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2021-02-22 14:31:37 +0100 |
commit | 1f08d2d03c158feadbadac58510eda2f93c6841a (patch) | |
tree | bc6441a7924e8f53d0ace3740a2c41f5416ffeae /src | |
parent | c1a695d1acc7bf5a70ee0791f36a253951c46251 (diff) |
zeroconf/avahi/Poll: add `noexcept`
Diffstat (limited to 'src')
-rw-r--r-- | src/zeroconf/avahi/Poll.cxx | 29 | ||||
-rw-r--r-- | src/zeroconf/avahi/Poll.hxx | 6 |
2 files changed, 20 insertions, 15 deletions
diff --git a/src/zeroconf/avahi/Poll.cxx b/src/zeroconf/avahi/Poll.cxx index ed836596c..c5f11969f 100644 --- a/src/zeroconf/avahi/Poll.cxx +++ b/src/zeroconf/avahi/Poll.cxx @@ -23,14 +23,14 @@ #include "time/Convert.hxx" static unsigned -FromAvahiWatchEvent(AvahiWatchEvent e) +FromAvahiWatchEvent(AvahiWatchEvent e) noexcept { return (e & AVAHI_WATCH_IN ? SocketEvent::READ : 0) | (e & AVAHI_WATCH_OUT ? SocketEvent::WRITE : 0); } static AvahiWatchEvent -ToAvahiWatchEvent(unsigned e) +ToAvahiWatchEvent(unsigned e) noexcept { return AvahiWatchEvent((e & SocketEvent::READ ? AVAHI_WATCH_IN : 0) | (e & SocketEvent::WRITE ? AVAHI_WATCH_OUT : 0) | @@ -49,22 +49,23 @@ struct AvahiWatch final { public: AvahiWatch(SocketDescriptor _fd, AvahiWatchEvent _event, AvahiWatchCallback _callback, void *_userdata, - EventLoop &_loop) + EventLoop &_loop) noexcept :event(_loop, BIND_THIS_METHOD(OnSocketReady), _fd), callback(_callback), userdata(_userdata), received(AvahiWatchEvent(0)) { event.Schedule(FromAvahiWatchEvent(_event)); } - static void WatchUpdate(AvahiWatch *w, AvahiWatchEvent event) { + static void WatchUpdate(AvahiWatch *w, + AvahiWatchEvent event) noexcept { w->event.Schedule(FromAvahiWatchEvent(event)); } - static AvahiWatchEvent WatchGetEvents(AvahiWatch *w) { + static AvahiWatchEvent WatchGetEvents(AvahiWatch *w) noexcept { return w->received; } - static void WatchFree(AvahiWatch *w) { + static void WatchFree(AvahiWatch *w) noexcept { delete w; } @@ -85,21 +86,22 @@ struct AvahiTimeout final { public: AvahiTimeout(const struct timeval *tv, AvahiTimeoutCallback _callback, void *_userdata, - EventLoop &_loop) + EventLoop &_loop) noexcept :timer(_loop, BIND_THIS_METHOD(OnTimeout)), callback(_callback), userdata(_userdata) { if (tv != nullptr) timer.Schedule(ToSteadyClockDuration(*tv)); } - static void TimeoutUpdate(AvahiTimeout *t, const struct timeval *tv) { + static void TimeoutUpdate(AvahiTimeout *t, + const struct timeval *tv) noexcept { if (tv != nullptr) t->timer.Schedule(ToSteadyClockDuration(*tv)); else t->timer.Cancel(); } - static void TimeoutFree(AvahiTimeout *t) { + static void TimeoutFree(AvahiTimeout *t) noexcept { delete t; } @@ -109,7 +111,8 @@ private: } }; -MyAvahiPoll::MyAvahiPoll(EventLoop &_loop):event_loop(_loop) +MyAvahiPoll::MyAvahiPoll(EventLoop &_loop) noexcept + :event_loop(_loop) { watch_new = WatchNew; watch_update = AvahiWatch::WatchUpdate; @@ -122,7 +125,8 @@ MyAvahiPoll::MyAvahiPoll(EventLoop &_loop):event_loop(_loop) AvahiWatch * MyAvahiPoll::WatchNew(const AvahiPoll *api, int fd, AvahiWatchEvent event, - AvahiWatchCallback callback, void *userdata) { + AvahiWatchCallback callback, void *userdata) noexcept +{ const MyAvahiPoll &poll = *(const MyAvahiPoll *)api; return new AvahiWatch(SocketDescriptor(fd), event, callback, userdata, @@ -131,7 +135,8 @@ MyAvahiPoll::WatchNew(const AvahiPoll *api, int fd, AvahiWatchEvent event, AvahiTimeout * MyAvahiPoll::TimeoutNew(const AvahiPoll *api, const struct timeval *tv, - AvahiTimeoutCallback callback, void *userdata) { + AvahiTimeoutCallback callback, void *userdata) noexcept +{ const MyAvahiPoll &poll = *(const MyAvahiPoll *)api; return new AvahiTimeout(tv, callback, userdata, diff --git a/src/zeroconf/avahi/Poll.hxx b/src/zeroconf/avahi/Poll.hxx index 80a3838c1..9dcbd4a27 100644 --- a/src/zeroconf/avahi/Poll.hxx +++ b/src/zeroconf/avahi/Poll.hxx @@ -28,7 +28,7 @@ class MyAvahiPoll final : public AvahiPoll { EventLoop &event_loop; public: - MyAvahiPoll(EventLoop &_loop); + explicit MyAvahiPoll(EventLoop &_loop) noexcept; MyAvahiPoll(const MyAvahiPoll &) = delete; MyAvahiPoll &operator=(const MyAvahiPoll &) = delete; @@ -41,12 +41,12 @@ private: static AvahiWatch *WatchNew(const AvahiPoll *api, int fd, AvahiWatchEvent event, AvahiWatchCallback callback, - void *userdata); + void *userdata) noexcept; static AvahiTimeout *TimeoutNew(const AvahiPoll *api, const struct timeval *tv, AvahiTimeoutCallback callback, - void *userdata); + void *userdata) noexcept; }; #endif |