ClientGlobal: move client_close_all() to ClientList.cxx
This commit is contained in:
parent
0194217f9d
commit
1998633739
|
@ -53,20 +53,9 @@ void client_manager_init(void)
|
|||
* 1024;
|
||||
}
|
||||
|
||||
static void client_close_all(void)
|
||||
{
|
||||
while (!client_list_is_empty()) {
|
||||
Client *client = client_list_get_first();
|
||||
|
||||
client->Close();
|
||||
}
|
||||
|
||||
assert(client_list_is_empty());
|
||||
}
|
||||
|
||||
void client_manager_deinit(void)
|
||||
{
|
||||
client_close_all();
|
||||
client_list_close_all();
|
||||
|
||||
client_max_connections = 0;
|
||||
}
|
||||
|
|
|
@ -29,26 +29,12 @@
|
|||
static std::list<Client *> clients;
|
||||
static unsigned num_clients;
|
||||
|
||||
bool
|
||||
client_list_is_empty(void)
|
||||
{
|
||||
return num_clients == 0;
|
||||
}
|
||||
|
||||
bool
|
||||
client_list_is_full(void)
|
||||
{
|
||||
return num_clients >= client_max_connections;
|
||||
}
|
||||
|
||||
Client *
|
||||
client_list_get_first(void)
|
||||
{
|
||||
assert(!clients.empty());
|
||||
|
||||
return clients.front();
|
||||
}
|
||||
|
||||
void
|
||||
client_list_add(Client *client)
|
||||
{
|
||||
|
@ -74,3 +60,12 @@ client_list_remove(Client *client)
|
|||
clients.erase(i);
|
||||
--num_clients;
|
||||
}
|
||||
|
||||
void
|
||||
client_list_close_all()
|
||||
{
|
||||
while (!clients.empty())
|
||||
clients.front()->Close();
|
||||
|
||||
assert(num_clients == 0);
|
||||
}
|
||||
|
|
|
@ -22,15 +22,9 @@
|
|||
|
||||
class Client;
|
||||
|
||||
bool
|
||||
client_list_is_empty(void);
|
||||
|
||||
bool
|
||||
client_list_is_full(void);
|
||||
|
||||
Client *
|
||||
client_list_get_first(void);
|
||||
|
||||
void
|
||||
client_list_add(Client *client);
|
||||
|
||||
|
@ -40,4 +34,7 @@ client_list_foreach(void (*callback)(Client *client, void *ctx), void *ctx);
|
|||
void
|
||||
client_list_remove(Client *client);
|
||||
|
||||
void
|
||||
client_list_close_all();
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue