550 if (timeout_control == TIMEOUT_TIMEDOUT) {
551 curPollTimeout += ((curPollTimeout>>2) + 1);
552 curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
553 if((int)curPollTimeout > AWT_POLL_THRESHOLD || (int)curPollTimeout == AWT_POLL_BLOCK)
554 curPollTimeout = AWT_POLL_BLOCK;
555 } else if (timeout_control == TIMEOUT_EVENTS) {
556 curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, 1);
557 }
558 break;
559 }
560 }
561
562 /*
563 * Gets the best timeout for the next call to poll().
564 *
565 * @param nextTaskTime -1, if there are no tasks; next time when
566 * timeout task needs to be run, in millis(of currentTimeMillis)
567 */
568 static uint32_t get_poll_timeout(jlong nextTaskTime)
569 {
570 uint32_t ret_timeout;
571 uint32_t timeout;
572 uint32_t taskTimeout;
573 uint32_t flushTimeout;
574
575 jlong curTime = awtJNI_TimeMillis();
576 timeout = curPollTimeout;
577 switch(awt_poll_alg) {
578 case AWT_POLL_AGING_SLOW:
579 case AWT_POLL_AGING_FAST:
580 taskTimeout = (nextTaskTime == -1) ? AWT_MAX_POLL_TIMEOUT : (uint32_t)max(0, (int32_t)(nextTaskTime - curTime));
581 flushTimeout = (awt_next_flush_time > 0) ? (uint32_t)max(0, (int32_t)(awt_next_flush_time - curTime)) : AWT_MAX_POLL_TIMEOUT;
582
583 PRINT2("to: %d, ft: %d, to: %d, tt: %d, mil: %d\n", taskTimeout, flushTimeout, timeout, (int)nextTaskTime, (int)curTime);
584
585 // Adjust timeout to flush_time and task_time
586 ret_timeout = min(flushTimeout, min(taskTimeout, timeout));
587 if((int)curPollTimeout == AWT_POLL_BLOCK)
588 ret_timeout = AWT_POLL_BLOCK;
589 break;
590
|
550 if (timeout_control == TIMEOUT_TIMEDOUT) {
551 curPollTimeout += ((curPollTimeout>>2) + 1);
552 curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
553 if((int)curPollTimeout > AWT_POLL_THRESHOLD || (int)curPollTimeout == AWT_POLL_BLOCK)
554 curPollTimeout = AWT_POLL_BLOCK;
555 } else if (timeout_control == TIMEOUT_EVENTS) {
556 curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, 1);
557 }
558 break;
559 }
560 }
561
562 /*
563 * Gets the best timeout for the next call to poll().
564 *
565 * @param nextTaskTime -1, if there are no tasks; next time when
566 * timeout task needs to be run, in millis(of currentTimeMillis)
567 */
568 static uint32_t get_poll_timeout(jlong nextTaskTime)
569 {
570 uint32_t ret_timeout = 0;
571 uint32_t timeout;
572 uint32_t taskTimeout;
573 uint32_t flushTimeout;
574
575 jlong curTime = awtJNI_TimeMillis();
576 timeout = curPollTimeout;
577 switch(awt_poll_alg) {
578 case AWT_POLL_AGING_SLOW:
579 case AWT_POLL_AGING_FAST:
580 taskTimeout = (nextTaskTime == -1) ? AWT_MAX_POLL_TIMEOUT : (uint32_t)max(0, (int32_t)(nextTaskTime - curTime));
581 flushTimeout = (awt_next_flush_time > 0) ? (uint32_t)max(0, (int32_t)(awt_next_flush_time - curTime)) : AWT_MAX_POLL_TIMEOUT;
582
583 PRINT2("to: %d, ft: %d, to: %d, tt: %d, mil: %d\n", taskTimeout, flushTimeout, timeout, (int)nextTaskTime, (int)curTime);
584
585 // Adjust timeout to flush_time and task_time
586 ret_timeout = min(flushTimeout, min(taskTimeout, timeout));
587 if((int)curPollTimeout == AWT_POLL_BLOCK)
588 ret_timeout = AWT_POLL_BLOCK;
589 break;
590
|