source: trunk/src/winmm/os2timer.h@ 757

Last change on this file since 757 was 757, checked in by phaller, 26 years ago

Fix: minimum and maximum resolution supported

File size: 3.6 KB
Line 
1/* $Id: os2timer.h,v 1.5 1999-08-31 15:39:21 phaller Exp $ */
2
3#ifndef __OS2TIMER_H__
4#define __OS2TIMER_H__
5/*
6 * OS/2 Timer class
7 *
8 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
9 * Copyright 1999 Patrick Haller (phaller@gmx.net)
10 *
11 * Project Odin Software License can be found in LICENSE.TXT
12 *
13 */
14
15#ifdef _OS2WIN_H
16 #define HEV int
17 #define HTIMER int
18#endif
19
20
21/****************************************************************************
22 * Definitions *
23 ****************************************************************************/
24
25#define OS2TIMER_RESOLUTION_MINIMUM 33
26#define OS2TIMER_RESOLUTION_MAXIMUM 65535
27
28
29/****************************************************************************
30 * Structures *
31 ****************************************************************************/
32
33#if 0
34typedef struct _MMTIMEREVENT
35{
36 struct _MMTIMEREVENT* prev;
37 struct _MMTIMEREVENT* next;
38
39 DWORD id; // event id
40 DWORD timeScheduled; // system time to fire event
41 DWORD timePeriod; // period if periodic event
42 TID tidCaller; // thread ID of caller thread
43 DWORD dwUser; // user supplied value
44 LPTIMERCALLBACK lpCallback; // address to call
45 DWORD dwFlags; // event flags
46} MMTIMEREVENT, *PMMTIMEREVENT, *LPTIMEREVENT;
47#endif
48
49/*
50 addEvent
51 removeEvent
52 rescheduleEvent
53 callbackCaller
54*/
55
56
57/****************************************************************************
58 * Class: OS2TimerResolution *
59 ****************************************************************************/
60
61class OS2TimerResolution
62{
63 public:
64 // public entries
65 static BOOL enterResolutionScope(int dwPeriod); // request timer resolution
66 static BOOL leaveResolutionScope(int dwPeriod); // release resolution request
67 static int queryCurrentResolution(); // query maximum resolution
68
69 // public variables
70 int dwPeriod;
71
72 protected:
73 // constructors and destructors
74 OS2TimerResolution(void);
75 OS2TimerResolution(int dwPeriod);
76 ~OS2TimerResolution();
77
78 // simple linked list
79 static OS2TimerResolution* sTimerResolutions; // list of resolution scoped
80 OS2TimerResolution* next; // link to next entry
81};
82
83
84/****************************************************************************
85 * Class: OS2Timer *
86 ****************************************************************************/
87
88class OS2Timer
89{
90public:
91 OS2Timer();
92 ~OS2Timer();
93
94 void TimerHandler();
95 BOOL StartTimer(int period, int resolution, LPTIMECALLBACK lptc,
96 int dwUser, int fuEvent);
97 void StopTimer();
98 void KillTimer();
99
100protected:
101
102private:
103 HEV TimerSem;
104 HTIMER TimerHandle;
105 int TimerThreadID;
106 LPTIMECALLBACK clientCallback;
107 DWORD userData;
108
109 BOOL fFatal;
110 int TimerStatus;
111 enum {
112 InActive = 0,
113 Running,
114 Stopped
115 };
116 static int timerPeriod;
117
118 // Linked list management
119 OS2Timer* next; // Next Timer
120 static OS2Timer* timers; // List of Timer
121
122};
123
124#endif
Note: See TracBrowser for help on using the repository browser.