Cygwin: (mostly) drop NT4 and Samba < 3.0 support
[newlib-cygwin.git] / winsup / cygwin / local_includes / posix_timer.h
blobe1cfe84c7b2db72c2f31af5742b910aeb730616b
1 /* timer.h: Define class timer_tracker, base class for posix timers
3 This file is part of Cygwin.
5 This software is a copyrighted work licensed under the terms of the
6 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
7 details. */
9 #ifndef __POSIX_TIMER_H__
10 #define __POSIX_TIMER_H__
12 #define TT_MAGIC 0x513e4a1c
13 class timer_tracker
15 unsigned magic;
16 SRWLOCK srwlock;
17 clockid_t clock_id;
18 sigevent evp;
19 struct itimerspec time_spec;
20 HANDLE timer;
21 HANDLE cancel_evt;
22 HANDLE sync_thr;
23 LONG64 interval;
24 LONG64 exp_ts;
25 LONG overrun_count_curr;
26 LONG64 overrun_count;
28 bool cancel ();
30 public:
31 void *operator new (size_t, void *p) __attribute__ ((nothrow)) {return p;}
32 void operator delete (void *p) { HeapFree (GetProcessHeap (), 0, p); }
33 timer_tracker (clockid_t, const sigevent *);
34 ~timer_tracker ();
35 inline bool is_timer_tracker () const { return magic == TT_MAGIC; }
36 inline sigevent_t *sigevt () { return &evp; }
37 inline int getoverrun () const { return overrun_count_curr; }
39 LONG64 get_clock_now () const { return get_clock (clock_id)->n100secs (); }
40 LONG64 get_exp_ts () const { return exp_ts; }
41 LONG64 get_interval () const { return interval; }
42 void set_exp_ts (LONG64 ts) { exp_ts = ts; }
44 bool arm_overrun_event (LONG64);
45 LONG disarm_overrun_event ();
47 int gettime (itimerspec *, bool);
48 int settime (int, const itimerspec *, itimerspec *);
50 DWORD thread_func ();
51 static void fixup_after_fork ();
54 #endif /* __POSIX_TIMER_H__ */