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

Last change on this file since 3600 was 3600, checked in by phaller, 25 years ago

Fix: WINMM: OS2Timer stuff

File size: 3.7 KB
Line 
1/* $Id: os2timer.h,v 1.9 2000-05-24 01:56:25 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 32
26#define OS2TIMER_RESOLUTION_MAXIMUM 0x7ffffffe
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 HANDLE hTimerThread;
106 DWORD TimerThreadID;
107 LPTIMECALLBACK clientCallback;
108 DWORD userData;
109 DWORD dwFlags; // corresponds with fuEvent
110
111 BOOL fFatal;
112 int TimerStatus;
113 enum {
114 InActive = 0,
115 Running,
116 Stopped
117 };
118 static int timerPeriod;
119
120 // Linked list management
121 OS2Timer* next; // Next Timer
122 static OS2Timer* timers; // List of Timer
123
124};
125
126#endif
Note: See TracBrowser for help on using the repository browser.