-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathServerStats.cpp
More file actions
39 lines (28 loc) · 804 Bytes
/
ServerStats.cpp
File metadata and controls
39 lines (28 loc) · 804 Bytes
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
#include <iostream>
#include "ServerStats.h"
// ctor
ServerStats::ServerStats()
{
numActiveClients = 0;
}
// accessors (getters)
int ServerStats::getHeadsTailsHS() { return headsTailsHS; }
int ServerStats::getLifetimeConnections() { return lifetimeConnections; }
int ServerStats::getNumActiveClients() { return numActiveClients; }
// mutators (setters)
void ServerStats::setHeadsTailsHS(int newScore)
{
pthread_mutex_lock(&highscoreLock);
if (newScore > headsTailsHS)
{
headsTailsHS = newScore;
pthread_mutex_unlock(&highscoreLock);
}
pthread_mutex_unlock(&highscoreLock);
}
void ServerStats::incrementNumActiveClients()
{
numActiveClients++;
lifetimeConnections++;
}
void ServerStats::decrementNumActiveClients() { numActiveClients--; }