refactor: Make throwError and throwNameError members of IArchNetwork
make throwError and throwNameError noreturn
remove unused extra private section in IArchNetwork subclasses
This commit is contained in:
parent
ab4fbd1c85
commit
2421a8b725
5 changed files with 19 additions and 10 deletions
|
|
@ -274,4 +274,15 @@ public:
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
virtual void init() = 0;
|
virtual void init() = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief throwError, Used to throw network errors
|
||||||
|
*/
|
||||||
|
[[noreturn]] virtual void throwError(int) const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief throwNameError, Errors related to client names.
|
||||||
|
*/
|
||||||
|
[[noreturn]] virtual void throwNameError(int) const = 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -742,7 +742,7 @@ const int *ArchNetworkBSD::getUnblockPipeForThread(ArchThread thread)
|
||||||
return unblockPipe;
|
return unblockPipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchNetworkBSD::throwError(int err) const
|
[[noreturn]] void ArchNetworkBSD::throwError(int err) const
|
||||||
{
|
{
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case EINTR:
|
case EINTR:
|
||||||
|
|
@ -813,7 +813,7 @@ void ArchNetworkBSD::throwError(int err) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchNetworkBSD::throwNameError(int err) const
|
[[noreturn]] void ArchNetworkBSD::throwNameError(int err) const
|
||||||
{
|
{
|
||||||
static const char *s_msg[] = {
|
static const char *s_msg[] = {
|
||||||
"The specified host is unknown", "The requested name is valid but does not have an IP address",
|
"The specified host is unknown", "The requested name is valid but does not have an IP address",
|
||||||
|
|
|
||||||
|
|
@ -104,10 +104,9 @@ private:
|
||||||
const int *getUnblockPipe();
|
const int *getUnblockPipe();
|
||||||
const int *getUnblockPipeForThread(ArchThread);
|
const int *getUnblockPipeForThread(ArchThread);
|
||||||
void setBlockingOnSocket(int fd, bool blocking) const;
|
void setBlockingOnSocket(int fd, bool blocking) const;
|
||||||
void throwError(int) const;
|
[[noreturn]] void throwError(int) const override;
|
||||||
void throwNameError(int) const;
|
[[noreturn]] void throwNameError(int) const override;
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<Deps> m_pDeps;
|
std::shared_ptr<Deps> m_pDeps;
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -840,7 +840,7 @@ bool ArchNetworkWinsock::isEqualAddr(ArchNetAddress a, ArchNetAddress b)
|
||||||
return (a == b || (a->m_len == b->m_len && memcmp(&a->m_addr, &b->m_addr, a->m_len) == 0));
|
return (a == b || (a->m_len == b->m_len && memcmp(&a->m_addr, &b->m_addr, a->m_len) == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchNetworkWinsock::throwError(int err)
|
[[noreturn]] void ArchNetworkWinsock::throwError(int err) const
|
||||||
{
|
{
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case WSAEACCES:
|
case WSAEACCES:
|
||||||
|
|
@ -910,7 +910,7 @@ void ArchNetworkWinsock::throwError(int err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchNetworkWinsock::throwNameError(int err)
|
[[noreturn]] void ArchNetworkWinsock::throwNameError(int err) const
|
||||||
{
|
{
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case WSAHOST_NOT_FOUND:
|
case WSAHOST_NOT_FOUND:
|
||||||
|
|
|
||||||
|
|
@ -92,10 +92,9 @@ private:
|
||||||
|
|
||||||
void setBlockingOnSocket(SOCKET, bool blocking);
|
void setBlockingOnSocket(SOCKET, bool blocking);
|
||||||
|
|
||||||
void throwError(int);
|
[[noreturn]] void throwError(int) const override;
|
||||||
void throwNameError(int);
|
[[noreturn]] void throwNameError(int) const override;
|
||||||
|
|
||||||
private:
|
|
||||||
using EventList = std::list<WSAEVENT>;
|
using EventList = std::list<WSAEVENT>;
|
||||||
|
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue