Mercurial > vim
comparison src/ex_docmd.c @ 17712:316ae5631c1d v8.1.1853
patch 8.1.1853: timers test is still flaky
commit https://github.com/vim/vim/commit/52953194afccbcb6c2fd013b7a9e2cfbf202b9d0
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 16 10:27:13 2019 +0200
patch 8.1.1853: timers test is still flaky
Problem: Timers test is still flaky.
Solution: Compute the time to sleep more accurately.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 16 Aug 2019 10:30:03 +0200 |
parents | 10696f279e20 |
children | 4a3dca734d36 |
comparison
equal
deleted
inserted
replaced
17711:09d3e7bf3709 | 17712:316ae5631c1d |
---|---|
7673 * Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second. | 7673 * Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second. |
7674 */ | 7674 */ |
7675 void | 7675 void |
7676 do_sleep(long msec) | 7676 do_sleep(long msec) |
7677 { | 7677 { |
7678 long done; | 7678 long done = 0; |
7679 long wait_now; | 7679 long wait_now; |
7680 # ifdef ELAPSED_FUNC | |
7681 elapsed_T start_tv; | |
7682 | |
7683 // Remember at what time we started, so that we know how much longer we | |
7684 // should wait after waiting for a bit. | |
7685 ELAPSED_INIT(start_tv); | |
7686 # endif | |
7680 | 7687 |
7681 cursor_on(); | 7688 cursor_on(); |
7682 out_flush_cursor(FALSE, FALSE); | 7689 out_flush_cursor(FALSE, FALSE); |
7683 for (done = 0; !got_int && done < msec; done += wait_now) | 7690 while (!got_int && done < msec) |
7684 { | 7691 { |
7685 wait_now = msec - done > 1000L ? 1000L : msec - done; | 7692 wait_now = msec - done > 1000L ? 1000L : msec - done; |
7686 #ifdef FEAT_TIMERS | 7693 #ifdef FEAT_TIMERS |
7687 { | 7694 { |
7688 long due_time = check_due_timer(); | 7695 long due_time = check_due_timer(); |
7698 #ifdef FEAT_SOUND | 7705 #ifdef FEAT_SOUND |
7699 if (has_any_sound_callback() && wait_now > 20L) | 7706 if (has_any_sound_callback() && wait_now > 20L) |
7700 wait_now = 20L; | 7707 wait_now = 20L; |
7701 #endif | 7708 #endif |
7702 ui_delay(wait_now, TRUE); | 7709 ui_delay(wait_now, TRUE); |
7710 | |
7703 #ifdef FEAT_JOB_CHANNEL | 7711 #ifdef FEAT_JOB_CHANNEL |
7704 if (has_any_channel()) | 7712 if (has_any_channel()) |
7705 ui_breakcheck_force(TRUE); | 7713 ui_breakcheck_force(TRUE); |
7706 else | 7714 else |
7707 #endif | 7715 #endif |
7708 ui_breakcheck(); | 7716 ui_breakcheck(); |
7709 #ifdef MESSAGE_QUEUE | 7717 #ifdef MESSAGE_QUEUE |
7710 /* Process the netbeans and clientserver messages that may have been | 7718 // Process the netbeans and clientserver messages that may have been |
7711 * received in the call to ui_breakcheck() when the GUI is in use. This | 7719 // received in the call to ui_breakcheck() when the GUI is in use. This |
7712 * may occur when running a test case. */ | 7720 // may occur when running a test case. |
7713 parse_queued_messages(); | 7721 parse_queued_messages(); |
7714 #endif | 7722 #endif |
7723 | |
7724 # ifdef ELAPSED_FUNC | |
7725 // actual time passed | |
7726 done = ELAPSED_FUNC(start_tv); | |
7727 # else | |
7728 // guestimate time passed (will actually be more) | |
7729 done += wait_now; | |
7730 # endif | |
7715 } | 7731 } |
7716 | 7732 |
7717 // If CTRL-C was typed to interrupt the sleep, drop the CTRL-C from the | 7733 // If CTRL-C was typed to interrupt the sleep, drop the CTRL-C from the |
7718 // input buffer, otherwise a following call to input() fails. | 7734 // input buffer, otherwise a following call to input() fails. |
7719 if (got_int) | 7735 if (got_int) |