--- /dev/null
+#ifndef _STATS_H
+#define _STATS_H 1
+
+#include <pthread.h>
+#include <string>
+
+// A thread that regularly writes out statistics, ie. a list of all connected clients
+// with some information about each.
+
+class StatsThread {
+public:
+ StatsThread(const std::string &stats_file, int stats_interval);
+ void run();
+ void stop();
+
+private:
+ // Recover the this pointer, and call do_work().
+ static void *do_work_thunk(void *arg);
+
+ void do_work();
+
+ std::string stats_file;
+ int stats_interval;
+
+ pthread_t worker_thread;
+ volatile bool should_stop;
+};
+
+#endif // !defined(_STATS_H)