client/*: add "noexcept"
This commit is contained in:
@@ -97,14 +97,14 @@ public:
|
|||||||
std::list<ClientMessage> messages;
|
std::list<ClientMessage> messages;
|
||||||
|
|
||||||
Client(EventLoop &loop, Partition &partition,
|
Client(EventLoop &loop, Partition &partition,
|
||||||
UniqueSocketDescriptor fd, int uid, int num);
|
UniqueSocketDescriptor fd, int uid, int num) noexcept;
|
||||||
|
|
||||||
~Client() {
|
~Client() noexcept {
|
||||||
if (FullyBufferedSocket::IsDefined())
|
if (FullyBufferedSocket::IsDefined())
|
||||||
FullyBufferedSocket::Close();
|
FullyBufferedSocket::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsConnected() const {
|
bool IsConnected() const noexcept {
|
||||||
return FullyBufferedSocket::IsDefined();
|
return FullyBufferedSocket::IsDefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,8 +113,8 @@ public:
|
|||||||
return !FullyBufferedSocket::IsDefined();
|
return !FullyBufferedSocket::IsDefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Close();
|
void Close() noexcept;
|
||||||
void SetExpired();
|
void SetExpired() noexcept;
|
||||||
|
|
||||||
bool Write(const void *data, size_t length);
|
bool Write(const void *data, size_t length);
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ public:
|
|||||||
* returns the uid of the client process, or a negative value
|
* returns the uid of the client process, or a negative value
|
||||||
* if the uid is unknown
|
* if the uid is unknown
|
||||||
*/
|
*/
|
||||||
int GetUID() const {
|
int GetUID() const noexcept {
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,24 +135,24 @@ public:
|
|||||||
* Is this client running on the same machine, connected with
|
* Is this client running on the same machine, connected with
|
||||||
* a local (UNIX domain) socket?
|
* a local (UNIX domain) socket?
|
||||||
*/
|
*/
|
||||||
bool IsLocal() const {
|
bool IsLocal() const noexcept {
|
||||||
return uid >= 0;
|
return uid >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned GetPermission() const {
|
unsigned GetPermission() const noexcept {
|
||||||
return permission;
|
return permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPermission(unsigned _permission) {
|
void SetPermission(unsigned _permission) noexcept {
|
||||||
permission = _permission;
|
permission = _permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send "idle" response to this client.
|
* Send "idle" response to this client.
|
||||||
*/
|
*/
|
||||||
void IdleNotify();
|
void IdleNotify() noexcept;
|
||||||
void IdleAdd(unsigned flags);
|
void IdleAdd(unsigned flags) noexcept;
|
||||||
bool IdleWait(unsigned flags);
|
bool IdleWait(unsigned flags) noexcept;
|
||||||
|
|
||||||
enum class SubscribeResult {
|
enum class SubscribeResult {
|
||||||
/** success */
|
/** success */
|
||||||
@@ -173,10 +173,10 @@ public:
|
|||||||
return subscriptions.find(channel_name) != subscriptions.end();
|
return subscriptions.find(channel_name) != subscriptions.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
SubscribeResult Subscribe(const char *channel);
|
SubscribeResult Subscribe(const char *channel) noexcept;
|
||||||
bool Unsubscribe(const char *channel);
|
bool Unsubscribe(const char *channel) noexcept;
|
||||||
void UnsubscribeAll();
|
void UnsubscribeAll() noexcept;
|
||||||
bool PushMessage(const ClientMessage &msg);
|
bool PushMessage(const ClientMessage &msg) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this client allowed to use the specified local file?
|
* Is this client allowed to use the specified local file?
|
||||||
@@ -231,7 +231,7 @@ private:
|
|||||||
void OnSocketClosed() override;
|
void OnSocketClosed() override;
|
||||||
|
|
||||||
/* callback for TimerEvent */
|
/* callback for TimerEvent */
|
||||||
void OnTimeout();
|
void OnTimeout() noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -239,7 +239,7 @@ client_manager_init();
|
|||||||
|
|
||||||
void
|
void
|
||||||
client_new(EventLoop &loop, Partition &partition,
|
client_new(EventLoop &loop, Partition &partition,
|
||||||
UniqueSocketDescriptor fd, SocketAddress address, int uid);
|
UniqueSocketDescriptor fd, SocketAddress address, int uid) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a printf-like formatted string to the client.
|
* Write a printf-like formatted string to the client.
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
void
|
void
|
||||||
Client::SetExpired()
|
Client::SetExpired() noexcept
|
||||||
{
|
{
|
||||||
if (IsExpired())
|
if (IsExpired())
|
||||||
return;
|
return;
|
||||||
@@ -32,7 +32,7 @@ Client::SetExpired()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Client::OnTimeout()
|
Client::OnTimeout() noexcept
|
||||||
{
|
{
|
||||||
if (!IsExpired()) {
|
if (!IsExpired()) {
|
||||||
assert(!idle_waiting);
|
assert(!idle_waiting);
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
Client::IdleNotify()
|
Client::IdleNotify() noexcept
|
||||||
{
|
{
|
||||||
assert(idle_waiting);
|
assert(idle_waiting);
|
||||||
assert(idle_flags != 0);
|
assert(idle_flags != 0);
|
||||||
@@ -46,7 +46,7 @@ Client::IdleNotify()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Client::IdleAdd(unsigned flags)
|
Client::IdleAdd(unsigned flags) noexcept
|
||||||
{
|
{
|
||||||
if (IsExpired())
|
if (IsExpired())
|
||||||
return;
|
return;
|
||||||
@@ -57,7 +57,7 @@ Client::IdleAdd(unsigned flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Client::IdleWait(unsigned flags)
|
Client::IdleWait(unsigned flags) noexcept
|
||||||
{
|
{
|
||||||
assert(!idle_waiting);
|
assert(!idle_waiting);
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@
|
|||||||
static constexpr char GREETING[] = "OK MPD " PROTOCOL_VERSION "\n";
|
static constexpr char GREETING[] = "OK MPD " PROTOCOL_VERSION "\n";
|
||||||
|
|
||||||
Client::Client(EventLoop &_loop, Partition &_partition,
|
Client::Client(EventLoop &_loop, Partition &_partition,
|
||||||
UniqueSocketDescriptor _fd, int _uid, int _num)
|
UniqueSocketDescriptor _fd, int _uid, int _num) noexcept
|
||||||
:FullyBufferedSocket(_fd.Release(), _loop,
|
:FullyBufferedSocket(_fd.Release(), _loop,
|
||||||
16384, client_max_output_buffer_size),
|
16384, client_max_output_buffer_size),
|
||||||
timeout_event(_loop, BIND_THIS_METHOD(OnTimeout)),
|
timeout_event(_loop, BIND_THIS_METHOD(OnTimeout)),
|
||||||
@@ -56,7 +56,7 @@ Client::Client(EventLoop &_loop, Partition &_partition,
|
|||||||
|
|
||||||
void
|
void
|
||||||
client_new(EventLoop &loop, Partition &partition,
|
client_new(EventLoop &loop, Partition &partition,
|
||||||
UniqueSocketDescriptor fd, SocketAddress address, int uid)
|
UniqueSocketDescriptor fd, SocketAddress address, int uid) noexcept
|
||||||
{
|
{
|
||||||
static unsigned int next_client_num;
|
static unsigned int next_client_num;
|
||||||
const auto remote = ToString(address);
|
const auto remote = ToString(address);
|
||||||
@@ -102,7 +102,7 @@ client_new(EventLoop &loop, Partition &partition,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Client::Close()
|
Client::Close() noexcept
|
||||||
{
|
{
|
||||||
partition->instance.client_list->Remove(*this);
|
partition->instance.client_list->Remove(*this);
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
Client::SubscribeResult
|
Client::SubscribeResult
|
||||||
Client::Subscribe(const char *channel)
|
Client::Subscribe(const char *channel) noexcept
|
||||||
{
|
{
|
||||||
assert(channel != nullptr);
|
assert(channel != nullptr);
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ Client::Subscribe(const char *channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Client::Unsubscribe(const char *channel)
|
Client::Unsubscribe(const char *channel) noexcept
|
||||||
{
|
{
|
||||||
const auto i = subscriptions.find(channel);
|
const auto i = subscriptions.find(channel);
|
||||||
if (i == subscriptions.end())
|
if (i == subscriptions.end())
|
||||||
@@ -67,14 +67,14 @@ Client::Unsubscribe(const char *channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Client::UnsubscribeAll()
|
Client::UnsubscribeAll() noexcept
|
||||||
{
|
{
|
||||||
subscriptions.clear();
|
subscriptions.clear();
|
||||||
num_subscriptions = 0;
|
num_subscriptions = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Client::PushMessage(const ClientMessage &msg)
|
Client::PushMessage(const ClientMessage &msg) noexcept
|
||||||
{
|
{
|
||||||
if (messages.size() >= CLIENT_MAX_MESSAGES ||
|
if (messages.size() >= CLIENT_MAX_MESSAGES ||
|
||||||
!IsSubscribed(msg.GetChannel()))
|
!IsSubscribed(msg.GetChannel()))
|
||||||
|
Reference in New Issue
Block a user