File: atimer.h

package info (click to toggle)
apcupsd 3.14.10-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 7,296 kB
  • sloc: ansic: 36,560; cpp: 7,912; sh: 3,981; makefile: 1,576; tcl: 368; objc: 276; php: 255
file content (42 lines) | stat: -rwxr-xr-x 656 bytes parent folder | download | duplicates (3)
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
#ifndef __ATIMER_H
#define __ATIMER_H

#include <pthread.h>
#include "athread.h"

class atimer: public athread
{
public:

   class client
   {
   public:
      virtual void HandleTimeout(int id) = 0;
   protected:
      client() {}
      virtual ~client() {}
   };

   atimer(client &cli, int id = 0);
   ~atimer();

   void start(unsigned long msec);
   void stop();

private:

   virtual void body();

   client &_client;
   int _id;
   pthread_mutex_t _mutex;
   pthread_cond_t _condvar;
   bool _started;
   struct timespec _abstimeout;

   // Prevent use
   atimer(const atimer &rhs);
   atimer &operator=(const atimer &rhs);
};

#endif // __ATIMER_H