Changeset 86 for trunk/src/helpers/timer.c
- Timestamp:
- Jul 15, 2001, 10:57:25 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/timer.c
r74 r86 71 71 72 72 /* 73 * Copyright (C) 2000 Ulrich Mller.73 * Copyright (C) 2000-2001 Ulrich Mller. 74 74 * This file is part of the "XWorkplace helpers" source package. 75 75 * This is free software; you can redistribute it and/or modify … … 109 109 #include "helpers\except.h" 110 110 #include "helpers\linklist.h" 111 #include "helpers\math.h" 111 112 #include "helpers\threads.h" 112 113 #include "helpers\timer.h" … … 241 242 * 242 243 *@@added V0.9.9 (2001-03-07) [umoeller] 244 *@@changed V0.9.14 (2001-07-07) [umoeller]: added GCD optimizations 243 245 */ 244 246 … … 265 267 { 266 268 // we have timers: 269 267 270 ULONG ulOldPMTimeout = pSet->ulPMTimeout; 268 pSet->ulPMTimeout = 1000; 269 270 while (pNode) 271 { 271 272 if (!pNode->pNext) 273 { 274 // only one timer: 275 // that's easy 272 276 PXTIMER pTimer = (PXTIMER)pNode->pItemData; 273 274 if ( (pTimer->ulTimeout / 2) < pSet->ulPMTimeout ) 275 pSet->ulPMTimeout = pTimer->ulTimeout / 2; 276 277 pNode = pNode->pNext; 277 pSet->ulPMTimeout = pTimer->ulTimeout; 278 } 279 else if (!pNode->pNext->pNext) 280 { 281 // exactly two timers: 282 // find the greatest common denominator 283 PXTIMER pTimer1 = (PXTIMER)pNode->pItemData, 284 pTimer2 = (PXTIMER)pNode->pNext->pItemData; 285 286 pSet->ulPMTimeout = mathGCD(pTimer1->ulTimeout, 287 pTimer2->ulTimeout); 288 } 289 else 290 { 291 // several timers: 292 // run through all timers and find the greatest 293 // common denominator of all frequencies... 294 295 ULONG cTimers = lstCountItems(pllXTimers); 296 int *paInts = (int*)_alloca(sizeof(int) * cTimers), 297 i = 0; 298 299 _Pmpf(("Recalculating, got %d timers %d", cTimers)); 300 301 // fill an array of integers with the 302 // timer frequencies 303 while (pNode) 304 { 305 PXTIMER pTimer = (PXTIMER)pNode->pItemData; 306 307 _Pmpf((" timeout %d is %d", i, pTimer->ulTimeout)); 308 309 paInts[i++] = pTimer->ulTimeout; 310 311 pNode = pNode->pNext; 312 } 313 314 pSet->ulPMTimeout = mathGCDMulti(paInts, 315 cTimers); 316 _Pmpf(("--> GCD is %d", pSet->ulPMTimeout)); 278 317 } 279 318 … … 518 557 * when the window is destroyed. 519 558 * 559 * Note: Unless you own the timer set that 560 * your timer runs on, it is strongly recommended 561 * that your timer frequency is set to a multiple 562 * of 125. The PM master timer behind the timer 563 * set will be set to the greatest common divisor 564 * of all frequencies, and if you set one timer 565 * to 2000 and the other one to 2001, you will 566 * cause quite a lot of overhead. This applies 567 * especially to timers started by XCenter widgets. 568 * 569 * For security, all timer frequencies will be 570 * rounded to multiples of 25 anyway. Still, 571 * running two timers at 1000 and 1025 will cause 572 * the master timer to be set to 25, which is 573 * overkill. 574 * 520 575 *@@changed V0.9.7 (2000-12-08) [umoeller]: got rid of dtGetULongTime 521 576 *@@changed V0.9.12 (2001-05-12) [umoeller]: added mutex protection 577 *@@changed V0.9.14 (2001-07-12) [umoeller]: now rounding freq's to multiples of 25 522 578 */ 523 579 … … 540 596 { 541 597 PXTIMER pTimer; 598 599 // fix the timeout... we allow only multiples of 600 // 20, and it must be at least 20 (otherwise our 601 // internal master timer calculations will fail) 602 // V0.9.14 (2001-07-07) [umoeller] 603 if (ulTimeout < 25) 604 ulTimeout = 25; 605 else 606 ulTimeout = (ulTimeout + 10) / 25 * 25; 542 607 543 608 // check if this timer exists already
Note:
See TracChangeset
for help on using the changeset viewer.