-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.go
46 lines (35 loc) · 785 Bytes
/
stats.go
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
package irc
import (
"sync"
)
// Stats contains the numbers of total, invisible and operators on the server
type Stats struct {
sync.RWMutex
Total int
Invisible int
Operators int
}
// ChangeTotal increments the total user count on server
func (s *Stats) ChangeTotal(i int) {
s.Lock()
defer s.Unlock()
s.Total += i
}
// ChangeInvisible increments the invisible count
func (s *Stats) ChangeInvisible(i int) {
s.Lock()
defer s.Unlock()
s.Invisible += i
}
// ChangeOperators increases the operator count
func (s *Stats) ChangeOperators(i int) {
s.Lock()
defer s.Unlock()
s.Operators += i
}
// GetStats retrives total, invisible and oper count
func (s *Stats) GetStats() (int, int, int) {
s.Lock()
defer s.Unlock()
return s.Total, s.Invisible, s.Operators
}