]> git.sesse.net Git - cubemap/blob - stats.h
Factor statistics writing into its own class and file.
[cubemap] / stats.h
1 #ifndef _STATS_H
2 #define _STATS_H 1
3
4 #include <pthread.h>
5 #include <string>
6
7 // A thread that regularly writes out statistics, ie. a list of all connected clients
8 // with some information about each.
9
10 class StatsThread {
11 public:
12         StatsThread(const std::string &stats_file, int stats_interval);
13         void run();
14         void stop();
15
16 private:
17         // Recover the this pointer, and call do_work().
18         static void *do_work_thunk(void *arg);
19
20         void do_work();
21
22         std::string stats_file;
23         int stats_interval;
24
25         pthread_t worker_thread;
26         volatile bool should_stop;
27 };
28         
29 #endif  // !defined(_STATS_H)