diff options
Diffstat (limited to '')
-rw-r--r-- | src/ClientList.cxx | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/src/ClientList.cxx b/src/ClientList.cxx index bfa04fea1..37e6f1289 100644 --- a/src/ClientList.cxx +++ b/src/ClientList.cxx @@ -21,51 +21,36 @@ #include "ClientList.hxx" #include "ClientInternal.hxx" -#include <list> #include <algorithm> #include <assert.h> -static std::list<Client *> clients; -static unsigned num_clients; - -bool -client_list_is_full(void) -{ - return num_clients >= client_max_connections; -} - void -client_list_add(Client *client) +ClientList::Remove(Client &client) { - clients.push_front(client); - ++num_clients; -} + assert(size > 0); + assert(!list.empty()); -void -client_list_foreach(void (*callback)(Client *client, void *ctx), void *ctx) -{ - for (Client *client : clients) - callback(client, ctx); + auto i = std::find(list.begin(), list.end(), &client); + assert(i != list.end()); + list.erase(i); + --size; } void -client_list_remove(Client *client) +ClientList::CloseAll() { - assert(num_clients > 0); - assert(!clients.empty()); + while (!list.empty()) + list.front()->Close(); - auto i = std::find(clients.begin(), clients.end(), client); - assert(i != clients.end()); - clients.erase(i); - --num_clients; + assert(size == 0); } void -client_list_close_all() +ClientList::IdleAdd(unsigned flags) { - while (!clients.empty()) - clients.front()->Close(); + assert(flags != 0); - assert(num_clients == 0); + for (const auto &client : list) + client->IdleAdd(flags); } |