zeroconf/avahi/Poll: add noexcept
This commit is contained in:
parent
c1a695d1ac
commit
1f08d2d03c
@ -23,14 +23,14 @@
|
|||||||
#include "time/Convert.hxx"
|
#include "time/Convert.hxx"
|
||||||
|
|
||||||
static unsigned
|
static unsigned
|
||||||
FromAvahiWatchEvent(AvahiWatchEvent e)
|
FromAvahiWatchEvent(AvahiWatchEvent e) noexcept
|
||||||
{
|
{
|
||||||
return (e & AVAHI_WATCH_IN ? SocketEvent::READ : 0) |
|
return (e & AVAHI_WATCH_IN ? SocketEvent::READ : 0) |
|
||||||
(e & AVAHI_WATCH_OUT ? SocketEvent::WRITE : 0);
|
(e & AVAHI_WATCH_OUT ? SocketEvent::WRITE : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static AvahiWatchEvent
|
static AvahiWatchEvent
|
||||||
ToAvahiWatchEvent(unsigned e)
|
ToAvahiWatchEvent(unsigned e) noexcept
|
||||||
{
|
{
|
||||||
return AvahiWatchEvent((e & SocketEvent::READ ? AVAHI_WATCH_IN : 0) |
|
return AvahiWatchEvent((e & SocketEvent::READ ? AVAHI_WATCH_IN : 0) |
|
||||||
(e & SocketEvent::WRITE ? AVAHI_WATCH_OUT : 0) |
|
(e & SocketEvent::WRITE ? AVAHI_WATCH_OUT : 0) |
|
||||||
@ -49,22 +49,23 @@ struct AvahiWatch final {
|
|||||||
public:
|
public:
|
||||||
AvahiWatch(SocketDescriptor _fd, AvahiWatchEvent _event,
|
AvahiWatch(SocketDescriptor _fd, AvahiWatchEvent _event,
|
||||||
AvahiWatchCallback _callback, void *_userdata,
|
AvahiWatchCallback _callback, void *_userdata,
|
||||||
EventLoop &_loop)
|
EventLoop &_loop) noexcept
|
||||||
:event(_loop, BIND_THIS_METHOD(OnSocketReady), _fd),
|
:event(_loop, BIND_THIS_METHOD(OnSocketReady), _fd),
|
||||||
callback(_callback), userdata(_userdata),
|
callback(_callback), userdata(_userdata),
|
||||||
received(AvahiWatchEvent(0)) {
|
received(AvahiWatchEvent(0)) {
|
||||||
event.Schedule(FromAvahiWatchEvent(_event));
|
event.Schedule(FromAvahiWatchEvent(_event));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WatchUpdate(AvahiWatch *w, AvahiWatchEvent event) {
|
static void WatchUpdate(AvahiWatch *w,
|
||||||
|
AvahiWatchEvent event) noexcept {
|
||||||
w->event.Schedule(FromAvahiWatchEvent(event));
|
w->event.Schedule(FromAvahiWatchEvent(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
static AvahiWatchEvent WatchGetEvents(AvahiWatch *w) {
|
static AvahiWatchEvent WatchGetEvents(AvahiWatch *w) noexcept {
|
||||||
return w->received;
|
return w->received;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WatchFree(AvahiWatch *w) {
|
static void WatchFree(AvahiWatch *w) noexcept {
|
||||||
delete w;
|
delete w;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,21 +86,22 @@ struct AvahiTimeout final {
|
|||||||
public:
|
public:
|
||||||
AvahiTimeout(const struct timeval *tv,
|
AvahiTimeout(const struct timeval *tv,
|
||||||
AvahiTimeoutCallback _callback, void *_userdata,
|
AvahiTimeoutCallback _callback, void *_userdata,
|
||||||
EventLoop &_loop)
|
EventLoop &_loop) noexcept
|
||||||
:timer(_loop, BIND_THIS_METHOD(OnTimeout)),
|
:timer(_loop, BIND_THIS_METHOD(OnTimeout)),
|
||||||
callback(_callback), userdata(_userdata) {
|
callback(_callback), userdata(_userdata) {
|
||||||
if (tv != nullptr)
|
if (tv != nullptr)
|
||||||
timer.Schedule(ToSteadyClockDuration(*tv));
|
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)
|
if (tv != nullptr)
|
||||||
t->timer.Schedule(ToSteadyClockDuration(*tv));
|
t->timer.Schedule(ToSteadyClockDuration(*tv));
|
||||||
else
|
else
|
||||||
t->timer.Cancel();
|
t->timer.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TimeoutFree(AvahiTimeout *t) {
|
static void TimeoutFree(AvahiTimeout *t) noexcept {
|
||||||
delete t;
|
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_new = WatchNew;
|
||||||
watch_update = AvahiWatch::WatchUpdate;
|
watch_update = AvahiWatch::WatchUpdate;
|
||||||
@ -122,7 +125,8 @@ MyAvahiPoll::MyAvahiPoll(EventLoop &_loop):event_loop(_loop)
|
|||||||
|
|
||||||
AvahiWatch *
|
AvahiWatch *
|
||||||
MyAvahiPoll::WatchNew(const AvahiPoll *api, int fd, AvahiWatchEvent event,
|
MyAvahiPoll::WatchNew(const AvahiPoll *api, int fd, AvahiWatchEvent event,
|
||||||
AvahiWatchCallback callback, void *userdata) {
|
AvahiWatchCallback callback, void *userdata) noexcept
|
||||||
|
{
|
||||||
const MyAvahiPoll &poll = *(const MyAvahiPoll *)api;
|
const MyAvahiPoll &poll = *(const MyAvahiPoll *)api;
|
||||||
|
|
||||||
return new AvahiWatch(SocketDescriptor(fd), event, callback, userdata,
|
return new AvahiWatch(SocketDescriptor(fd), event, callback, userdata,
|
||||||
@ -131,7 +135,8 @@ MyAvahiPoll::WatchNew(const AvahiPoll *api, int fd, AvahiWatchEvent event,
|
|||||||
|
|
||||||
AvahiTimeout *
|
AvahiTimeout *
|
||||||
MyAvahiPoll::TimeoutNew(const AvahiPoll *api, const struct timeval *tv,
|
MyAvahiPoll::TimeoutNew(const AvahiPoll *api, const struct timeval *tv,
|
||||||
AvahiTimeoutCallback callback, void *userdata) {
|
AvahiTimeoutCallback callback, void *userdata) noexcept
|
||||||
|
{
|
||||||
const MyAvahiPoll &poll = *(const MyAvahiPoll *)api;
|
const MyAvahiPoll &poll = *(const MyAvahiPoll *)api;
|
||||||
|
|
||||||
return new AvahiTimeout(tv, callback, userdata,
|
return new AvahiTimeout(tv, callback, userdata,
|
||||||
|
@ -28,7 +28,7 @@ class MyAvahiPoll final : public AvahiPoll {
|
|||||||
EventLoop &event_loop;
|
EventLoop &event_loop;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MyAvahiPoll(EventLoop &_loop);
|
explicit MyAvahiPoll(EventLoop &_loop) noexcept;
|
||||||
|
|
||||||
MyAvahiPoll(const MyAvahiPoll &) = delete;
|
MyAvahiPoll(const MyAvahiPoll &) = delete;
|
||||||
MyAvahiPoll &operator=(const MyAvahiPoll &) = delete;
|
MyAvahiPoll &operator=(const MyAvahiPoll &) = delete;
|
||||||
@ -41,12 +41,12 @@ private:
|
|||||||
static AvahiWatch *WatchNew(const AvahiPoll *api, int fd,
|
static AvahiWatch *WatchNew(const AvahiPoll *api, int fd,
|
||||||
AvahiWatchEvent event,
|
AvahiWatchEvent event,
|
||||||
AvahiWatchCallback callback,
|
AvahiWatchCallback callback,
|
||||||
void *userdata);
|
void *userdata) noexcept;
|
||||||
|
|
||||||
static AvahiTimeout *TimeoutNew(const AvahiPoll *api,
|
static AvahiTimeout *TimeoutNew(const AvahiPoll *api,
|
||||||
const struct timeval *tv,
|
const struct timeval *tv,
|
||||||
AvahiTimeoutCallback callback,
|
AvahiTimeoutCallback callback,
|
||||||
void *userdata);
|
void *userdata) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user