mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 13:38:34 +00:00
refactor(time): refactor delay with input checking
Previously, there were three low-level delay entry points - os_delay(ms, ignoreinput=true): sleep for ms, only break on got_int - os_delay(ms, ignoreinput=false): sleep for ms, break on any key input os_microdelay(us, false): equivalent, but in μs (not directly called) - os_microdelay(us, true): sleep for μs, never break. The implementation of the latter two both used uv_cond_timedwait() This could have been for two reasons: 1. allow another thread to "interrupt" the wait 2. uv_cond_timedwait() has higher resolution than uv_sleep() However we (1) never used the first, even when TUI was a thread, and (2) nowhere in the codebase are we using μs resolution, it is always a ms multiplied with 1000. In addition, os_delay(ms, false) would completely block the thread for 100ms intervals and in between check for input. This is not how event handling is done alound here. Therefore: Replace the implementation of os_delay(ms, false) to use LOOP_PROCESS_EVENTS_UNTIL which does a proper epoll wait with a timeout, instead of the 100ms timer panic. Replace os_microdelay(us, false) with a direct wrapper of uv_sleep.
This commit is contained in:
@@ -467,7 +467,7 @@ static void debug_delay(Integer lines)
|
||||
ui_call_flush();
|
||||
uint64_t wd = (uint64_t)labs(p_wd);
|
||||
uint64_t factor = (uint64_t)MAX(MIN(lines, 5), 1);
|
||||
os_microdelay(factor * wd * 1000U, true);
|
||||
os_sleep(factor * wd);
|
||||
}
|
||||
|
||||
static void compose_area(Integer startrow, Integer endrow, Integer startcol, Integer endcol)
|
||||
|
Reference in New Issue
Block a user