libtasks Documentation  1.6
thrift_server/stats.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014 ADTECH GmbH
3  * Licensed under MIT (https://github.com/adtechlabs/libtasks/blob/master/COPYING)
4  *
5  * Author: Andreas Pohl
6  */
7 
8 #ifndef _STATS_H_
9 #define _STATS_H_
10 
11 #include <tasks/timer_task.h>
12 #include <atomic>
13 #include <ctime>
14 
15 class stats : public tasks::timer_task {
16  public:
17  stats() : timer_task(10., 10.) { m_last = std::time(nullptr); }
18 
19  bool handle_event(tasks::worker*, int revents);
20 
21  static void inc_req() { m_req_count++; }
22 
23  static void inc_clients() { m_clients++; }
24 
25  static void dec_clients() { m_clients--; }
26 
27  private:
28  static std::atomic<int> m_req_count;
29  static std::atomic<int> m_clients;
30  std::time_t m_last;
31 };
32 
33 #endif // _STATS_H_
static void inc_clients()
bool handle_event(tasks::worker *, int revents)
Definition: echoserver.cpp:72
static std::atomic< int > m_req_count
Definition: echoserver.h:32
static std::atomic< int > m_clients
Definition: echoserver.h:33
static void inc_req()
std::time_t m_last
Definition: echoserver.h:34
timer_task(double after, double repeat)
Definition: timer_task.cpp:15
static void dec_clients()