1 /*
2 * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
562 if (timeout_control == TIMEOUT_TIMEDOUT) {
563 curPollTimeout += ((curPollTimeout>>2) + 1);
564 curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
565 if((int)curPollTimeout > AWT_POLL_THRESHOLD || (int)curPollTimeout == AWT_POLL_BLOCK)
566 curPollTimeout = AWT_POLL_BLOCK;
567 } else if (timeout_control == TIMEOUT_EVENTS) {
568 curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, 1);
569 }
570 break;
571 }
572 }
573
574 /*
575 * Gets the best timeout for the next call to poll().
576 *
577 * @param nextTaskTime -1, if there are no tasks; next time when
578 * timeout task needs to be run, in millis(of currentTimeMillis)
579 */
580 static uint32_t get_poll_timeout(jlong nextTaskTime)
581 {
582 uint32_t ret_timeout;
583 uint32_t timeout;
584 uint32_t taskTimeout;
585 uint32_t flushTimeout;
586
587 jlong curTime = awtJNI_TimeMillis();
588 timeout = curPollTimeout;
589 switch(awt_poll_alg) {
590 case AWT_POLL_AGING_SLOW:
591 case AWT_POLL_AGING_FAST:
592 taskTimeout = (nextTaskTime == -1) ? AWT_MAX_POLL_TIMEOUT : (uint32_t)max(0, (int32_t)(nextTaskTime - curTime));
593 flushTimeout = (awt_next_flush_time > 0) ? (uint32_t)max(0, (int32_t)(awt_next_flush_time - curTime)) : AWT_MAX_POLL_TIMEOUT;
594
595 PRINT2("to: %d, ft: %d, to: %d, tt: %d, mil: %d\n", taskTimeout, flushTimeout, timeout, (int)nextTaskTime, (int)curTime);
596
597 // Adjust timeout to flush_time and task_time
598 ret_timeout = min(flushTimeout, min(taskTimeout, timeout));
599 if((int)curPollTimeout == AWT_POLL_BLOCK)
600 ret_timeout = AWT_POLL_BLOCK;
601 break;
602
|
1 /*
2 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
562 if (timeout_control == TIMEOUT_TIMEDOUT) {
563 curPollTimeout += ((curPollTimeout>>2) + 1);
564 curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
565 if((int)curPollTimeout > AWT_POLL_THRESHOLD || (int)curPollTimeout == AWT_POLL_BLOCK)
566 curPollTimeout = AWT_POLL_BLOCK;
567 } else if (timeout_control == TIMEOUT_EVENTS) {
568 curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, 1);
569 }
570 break;
571 }
572 }
573
574 /*
575 * Gets the best timeout for the next call to poll().
576 *
577 * @param nextTaskTime -1, if there are no tasks; next time when
578 * timeout task needs to be run, in millis(of currentTimeMillis)
579 */
580 static uint32_t get_poll_timeout(jlong nextTaskTime)
581 {
582 uint32_t ret_timeout = 0;
583 uint32_t timeout;
584 uint32_t taskTimeout;
585 uint32_t flushTimeout;
586
587 jlong curTime = awtJNI_TimeMillis();
588 timeout = curPollTimeout;
589 switch(awt_poll_alg) {
590 case AWT_POLL_AGING_SLOW:
591 case AWT_POLL_AGING_FAST:
592 taskTimeout = (nextTaskTime == -1) ? AWT_MAX_POLL_TIMEOUT : (uint32_t)max(0, (int32_t)(nextTaskTime - curTime));
593 flushTimeout = (awt_next_flush_time > 0) ? (uint32_t)max(0, (int32_t)(awt_next_flush_time - curTime)) : AWT_MAX_POLL_TIMEOUT;
594
595 PRINT2("to: %d, ft: %d, to: %d, tt: %d, mil: %d\n", taskTimeout, flushTimeout, timeout, (int)nextTaskTime, (int)curTime);
596
597 // Adjust timeout to flush_time and task_time
598 ret_timeout = min(flushTimeout, min(taskTimeout, timeout));
599 if((int)curPollTimeout == AWT_POLL_BLOCK)
600 ret_timeout = AWT_POLL_BLOCK;
601 break;
602
|