Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package irc
  2. import (
  3. "sync"
  4. )
  5. // Stats contains the numbers of total, invisible and operators on the server
  6. type Stats struct {
  7. sync.RWMutex
  8. Total int
  9. Invisible int
  10. Operators int
  11. }
  12. // ChangeTotal increments the total user count on server
  13. func (s *Stats) ChangeTotal(i int) {
  14. s.Lock()
  15. defer s.Unlock()
  16. s.Total += i
  17. }
  18. // ChangeInvisible increments the invisible count
  19. func (s *Stats) ChangeInvisible(i int) {
  20. s.Lock()
  21. defer s.Unlock()
  22. s.Invisible += i
  23. }
  24. // ChangeOperators increases the operator count
  25. func (s *Stats) ChangeOperators(i int) {
  26. s.Lock()
  27. defer s.Unlock()
  28. s.Operators += i
  29. }
  30. // GetStats retrives total, invisible and oper count
  31. func (s *Stats) GetStats() (int, int, int) {
  32. s.Lock()
  33. defer s.Unlock()
  34. return s.Total, s.Invisible, s.Operators
  35. }