Welcome to mirror list, hosted at ThFree Co, Russian Federation.

posix_timer.h « local_includes « cygwin « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e1cfe84c7b2db72c2f31af5742b910aeb730616b (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
/* timer.h: Define class timer_tracker, base class for posix timers

This file is part of Cygwin.

This software is a copyrighted work licensed under the terms of the
Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
details. */

#ifndef __POSIX_TIMER_H__
#define __POSIX_TIMER_H__

#define TT_MAGIC 0x513e4a1c
class timer_tracker
{
  unsigned magic;
  SRWLOCK srwlock;
  clockid_t clock_id;
  sigevent evp;
  struct itimerspec time_spec;
  HANDLE timer;
  HANDLE cancel_evt;
  HANDLE sync_thr;
  LONG64 interval;
  LONG64 exp_ts;
  LONG overrun_count_curr;
  LONG64 overrun_count;

  bool cancel ();

 public:
  void *operator new (size_t, void *p) __attribute__ ((nothrow)) {return p;}
  void operator delete (void *p) { HeapFree (GetProcessHeap (), 0, p); }
  timer_tracker (clockid_t, const sigevent *);
  ~timer_tracker ();
  inline bool is_timer_tracker () const { return magic == TT_MAGIC; }
  inline sigevent_t *sigevt () { return &evp; }
  inline int getoverrun () const { return overrun_count_curr; }

  LONG64 get_clock_now () const { return get_clock (clock_id)->n100secs (); }
  LONG64 get_exp_ts () const { return exp_ts; }
  LONG64 get_interval () const { return interval; }
  void set_exp_ts (LONG64 ts) { exp_ts = ts; }

  bool arm_overrun_event (LONG64);
  LONG disarm_overrun_event ();

  int gettime (itimerspec *, bool);
  int settime (int, const itimerspec *, itimerspec *);

  DWORD thread_func ();
  static void fixup_after_fork ();
};

#endif /* __POSIX_TIMER_H__ */