event/SocketMonitor: add "noexcept"
This commit is contained in:
parent
9d4020501c
commit
59a8836924
|
@ -142,7 +142,7 @@ private:
|
|||
void Disconnect();
|
||||
|
||||
/* virtual methods from SocketMonitor */
|
||||
bool OnSocketReady(unsigned flags) override;
|
||||
bool OnSocketReady(unsigned flags) noexcept override;
|
||||
|
||||
/* virtual methods from IdleMonitor */
|
||||
void OnIdle() override;
|
||||
|
@ -459,7 +459,7 @@ ProxyDatabase::Disconnect()
|
|||
}
|
||||
|
||||
bool
|
||||
ProxyDatabase::OnSocketReady(gcc_unused unsigned flags)
|
||||
ProxyDatabase::OnSocketReady(gcc_unused unsigned flags) noexcept
|
||||
{
|
||||
assert(connection != nullptr);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <limits.h>
|
||||
|
||||
bool
|
||||
InotifySource::OnSocketReady(gcc_unused unsigned flags)
|
||||
InotifySource::OnSocketReady(gcc_unused unsigned flags) noexcept
|
||||
{
|
||||
uint8_t buffer[4096];
|
||||
static_assert(sizeof(buffer) >= sizeof(struct inotify_event) + NAME_MAX + 1,
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
void Remove(unsigned wd);
|
||||
|
||||
private:
|
||||
virtual bool OnSocketReady(unsigned flags) override;
|
||||
bool OnSocketReady(unsigned flags) noexcept override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -99,7 +99,7 @@ BufferedSocket::ResumeInput()
|
|||
}
|
||||
|
||||
bool
|
||||
BufferedSocket::OnSocketReady(unsigned flags)
|
||||
BufferedSocket::OnSocketReady(unsigned flags) noexcept
|
||||
{
|
||||
assert(IsDefined());
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -256,7 +256,7 @@ EventLoop::HandleDeferred()
|
|||
}
|
||||
|
||||
bool
|
||||
EventLoop::OnSocketReady(gcc_unused unsigned flags)
|
||||
EventLoop::OnSocketReady(gcc_unused unsigned flags) noexcept
|
||||
{
|
||||
assert(IsInside());
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ private:
|
|||
*/
|
||||
void HandleDeferred();
|
||||
|
||||
virtual bool OnSocketReady(unsigned flags) override;
|
||||
bool OnSocketReady(unsigned flags) noexcept override;
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
curl_socket_t s, int action,
|
||||
void *userp, void *socketp) noexcept;
|
||||
|
||||
virtual bool OnSocketReady(unsigned flags) override;
|
||||
bool OnSocketReady(unsigned flags) noexcept override;
|
||||
|
||||
private:
|
||||
static constexpr int FlagsToCurlCSelect(unsigned flags) {
|
||||
|
@ -145,7 +145,7 @@ CurlSocket::SocketFunction(gcc_unused CURL *easy,
|
|||
}
|
||||
|
||||
bool
|
||||
CurlSocket::OnSocketReady(unsigned flags)
|
||||
CurlSocket::OnSocketReady(unsigned flags) noexcept
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
|
||||
|
|
|
@ -446,7 +446,7 @@ NfsConnection::Service(unsigned flags)
|
|||
}
|
||||
|
||||
bool
|
||||
NfsConnection::OnSocketReady(unsigned flags)
|
||||
NfsConnection::OnSocketReady(unsigned flags) noexcept
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(deferred_close.empty());
|
||||
|
|
|
@ -230,7 +230,7 @@ private:
|
|||
int Service(unsigned flags);
|
||||
|
||||
/* virtual methods from SocketMonitor */
|
||||
virtual bool OnSocketReady(unsigned flags) override;
|
||||
bool OnSocketReady(unsigned flags) noexcept override;
|
||||
|
||||
/* callback for #mount_timeout_event */
|
||||
void OnMountTimeout();
|
||||
|
|
|
@ -403,7 +403,7 @@ HttpdClient::PushMetaData(PagePtr page)
|
|||
}
|
||||
|
||||
bool
|
||||
HttpdClient::OnSocketReady(unsigned flags)
|
||||
HttpdClient::OnSocketReady(unsigned flags) noexcept
|
||||
{
|
||||
if (!BufferedSocket::OnSocketReady(flags))
|
||||
return false;
|
||||
|
|
|
@ -191,7 +191,9 @@ private:
|
|||
void ClearQueue();
|
||||
|
||||
protected:
|
||||
virtual bool OnSocketReady(unsigned flags) override;
|
||||
/* virtual methods from class SocketMonitor */
|
||||
bool OnSocketReady(unsigned flags) noexcept override;
|
||||
|
||||
virtual InputResult OnSocketInput(void *data, size_t length) override;
|
||||
void OnSocketError(std::exception_ptr ep) override;
|
||||
virtual void OnSocketClosed() override;
|
||||
|
|
|
@ -69,8 +69,9 @@ public:
|
|||
delete w;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool OnSocketReady(unsigned flags) {
|
||||
private:
|
||||
/* virtual methods from class SocketMonitor */
|
||||
bool OnSocketReady(unsigned flags) noexcept {
|
||||
received = ToAvahiWatchEvent(flags);
|
||||
callback(this, Get().Get(), received, userdata);
|
||||
received = AvahiWatchEvent(0);
|
||||
|
|
|
@ -48,7 +48,8 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
virtual bool OnSocketReady(gcc_unused unsigned flags) override {
|
||||
/* virtual methods from class SocketMonitor */
|
||||
bool OnSocketReady(gcc_unused unsigned flags) noexcept override {
|
||||
DNSServiceProcessResult(service_ref);
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue