Changeset 3600 for trunk/src/winmm/os2timer.cpp
- Timestamp:
- May 24, 2000, 3:56:25 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/winmm/os2timer.cpp
r2812 r3600 1 /* $Id: os2timer.cpp,v 1.1 4 2000-02-17 14:09:32 sandervlExp $ */1 /* $Id: os2timer.cpp,v 1.15 2000-05-24 01:56:25 phaller Exp $ */ 2 2 3 3 /* … … 51 51 DWORD fdwCreate, 52 52 LPDWORD lpIDThread); 53 54 VOID WIN32API ExitThread(DWORD dwExitCode); 55 56 BOOL WIN32API TerminateThread(HANDLE hThread, 57 DWORD dwExitCode); 58 59 BOOL WIN32API SetEvent (HANDLE hEvent); 60 61 BOOL WIN32API PulseEvent (HANDLE hEvent); 62 53 63 } 54 64 … … 238 248 /******************************************************************************/ 239 249 /******************************************************************************/ 240 OS2Timer::OS2Timer() : TimerSem(0), TimerHandle(0), TimerThreadID(0),250 OS2Timer::OS2Timer() : TimerSem(0), TimerHandle(0), hTimerThread(0), 241 251 clientCallback(NULL), TimerStatus(Stopped), fFatal(FALSE), 242 252 next(NULL) … … 257 267 else 258 268 timers = this; 259 260 // TimerThreadID= _beginthread(TimerHlpHandler, NULL, 0x4000, (void *)this);269 270 //hTimerThread = _beginthread(TimerHlpHandler, NULL, 0x4000, (void *)this); 261 271 hTimerThread = CreateThread(NULL, 262 272 0x4000, … … 266 276 &TimerThreadID); 267 277 268 269 278 //@@@PH: CreateThread() should be used instead 270 279 //@@@PH: logic sux ... waits for creation of semaphores 271 DosSleep(10 0);280 DosSleep(10); 272 281 } 273 282 /******************************************************************************/ … … 310 319 311 320 APIRET rc; 312 313 if(TimerThreadID == -1) 321 322 // has the thread been created properly? 323 if(hTimerThread == NULLHANDLE) 314 324 return(FALSE); 315 325 316 326 if(TimerStatus == Stopped) 317 327 { 318 clientCallback = lptc; 319 userData = dwUser; 320 321 if(fuEvent == TIME_PERIODIC) 328 clientCallback = lptc; // callback data (id / addr) 329 userData = dwUser; // user-supplied data 330 dwFlags = fuEvent; // type of timer / callback 331 332 if(fuEvent & TIME_PERIODIC) 322 333 rc = DosStartTimer(period, (HSEM)TimerSem, &TimerHandle); 323 334 else … … 328 339 329 340 #ifdef DEBUG 330 if(fuEvent ==TIME_PERIODIC)341 if(fuEvent & TIME_PERIODIC) 331 342 WriteLog("DosStartTimer failed %d\n", rc); 332 343 else … … 365 376 366 377 fFatal = TRUE; 367 DosStopTimer(TimerHandle); 378 379 StopTimer(); 380 368 381 if(DosPostEventSem(TimerSem)) 369 { //something went wrong370 DosKillThread(TimerThreadID);371 DosCloseEventSem(TimerSem);382 { 383 //something went wrong, kill the thread 384 TerminateThread(hTimerThread, -1); 372 385 } 373 386 TimerStatus = InActive; … … 406 419 // @@@PH: we're calling the client with PRTYC_TIMECRITICAL !!! 407 420 // It'd be much nicer to call with original priority! 408 409 selTIB = SetWin32TIB(); 410 clientCallback((UINT)this, 0, userData, 0, 0); 411 SetFS(selTIB); 412 } 413 } 421 422 // check timer running condition 423 if (TimerStatus == Running) 424 { 425 // process the event 426 switch (dwFlags & 0x0030) 427 { 428 case TIME_CALLBACK_FUNCTION: 429 if (clientCallback != NULL) 430 { 431 selTIB = SetWin32TIB(); 432 clientCallback((UINT)this, 0, userData, 0, 0); 433 SetFS(selTIB); 434 } 435 break; 436 437 case TIME_CALLBACK_EVENT_SET: 438 SetEvent( (HANDLE)clientCallback ); 439 break; 440 441 case TIME_CALLBACK_EVENT_PULSE: 442 PulseEvent( (HANDLE)clientCallback ); 443 break; 444 445 default: 446 dprintf(("WINMM: OS2Timer %08xh: unknown type for mmtime callback(%08xh)\n", 447 this, 448 dwFlags)); 449 } 450 } 451 } 452 } 453 454 // last message 455 dprintf(("WINMM: OS2Timer: Timer thread terminating (%08xh)\n", 456 this)); 457 414 458 DosCloseEventSem(TimerSem); 459 460 // mark this thread as terminated 461 ExitThread(0); 415 462 } 416 463 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.