-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathqueueManager.h
More file actions
67 lines (56 loc) · 1.16 KB
/
Copy pathqueueManager.h
File metadata and controls
67 lines (56 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
void queue_add_client(client_t *client)
{
pthread_mutex_lock(&clients_mutex);
for (int i = 0; i < MAX_CLIENTS; i++)
{
if (!clients[i])
{
clients[i] = client;
break;
}
}
pthread_mutex_unlock(&clients_mutex);
}
void queue_remove_client(int uid)
{
pthread_mutex_lock(&clients_mutex);
for (int i = 0; i < MAX_CLIENTS; i++)
{
if (clients[i])
{
if (clients[i]->uid == uid)
{
clients[i] = NULL;
}
}
}
pthread_mutex_unlock(&clients_mutex);
}
void queue_add_room(room_t *room)
{
pthread_mutex_lock(&rooms_mutex);
for (int i = 0; i < MAX_ROOMS; i++)
{
if (!rooms[i])
{
rooms[i] = room;
break;
}
}
pthread_mutex_unlock(&rooms_mutex);
}
void queue_remove_room(int uid)
{
pthread_mutex_lock(&rooms_mutex);
for (int i = 0; i < MAX_ROOMS; i++)
{
if (rooms[i])
{
if (rooms[i]->uid == uid)
{
rooms[i] = NULL;
}
}
}
pthread_mutex_unlock(&rooms_mutex);
}