aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/main.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-04-23 19:02:23 +0200
committerbfredl <bjorn.linse@gmail.com>2023-04-24 17:38:19 +0200
commit0d2fe7786537ef63d0d3ed1e94546eb3ee35a368 (patch)
treef479da09da4436af82dc015646ab519556c81750 /src/nvim/main.c
parent3ac952d4e27f4e2454332a730310316fe13fd4a3 (diff)
downloadrneovim-0d2fe7786537ef63d0d3ed1e94546eb3ee35a368.tar.gz
rneovim-0d2fe7786537ef63d0d3ed1e94546eb3ee35a368.tar.bz2
rneovim-0d2fe7786537ef63d0d3ed1e94546eb3ee35a368.zip
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.
Diffstat (limited to 'src/nvim/main.c')
-rw-r--r--src/nvim/main.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c
index db366160f6..657f9c67f2 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -173,7 +173,7 @@ bool event_teardown(void)
/// Performs early initialization.
///
-/// Needed for unit tests. Must be called after `time_init()`.
+/// Needed for unit tests.
void early_init(mparm_T *paramp)
{
estack_init();
@@ -261,7 +261,6 @@ int main(int argc, char **argv)
mparm_T params; // various parameters passed between
// main() and other functions.
char *cwd = NULL; // current working dir on startup
- time_init();
// Many variables are in `params` so that we can pass them around easily.
// `argc` and `argv` are also copied, so that they can be changed.