Mercurial > vim
comparison src/os_win32.c @ 29220:d6f8b784d0f6 v8.2.5129
patch 8.2.5129: timeout handling is not optimal
Commit: https://github.com/vim/vim/commit/1f30caff8b63beda75a5dcd15ffe3e9e818ed483
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 19 14:36:35 2022 +0100
patch 8.2.5129: timeout handling is not optimal
Problem: Timeout handling is not optimal.
Solution: Avoid setting timeout_flag twice. Adjust the pointer when
stopping the regexp timeout. Adjust variable name.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 19 Jun 2022 15:45:02 +0200 |
parents | 35a30cb18005 |
children | b12fd2b3be63 |
comparison
equal
deleted
inserted
replaced
29219:aad416d6fb3f | 29220:d6f8b784d0f6 |
---|---|
8333 * set_flag() function may still be invoked after the previous timer is | 8333 * set_flag() function may still be invoked after the previous timer is |
8334 * deleted. Ping-ponging between the two flags prevents this causing 'fake' | 8334 * deleted. Ping-ponging between the two flags prevents this causing 'fake' |
8335 * timeouts. | 8335 * timeouts. |
8336 */ | 8336 */ |
8337 static int timeout_flags[2]; | 8337 static int timeout_flags[2]; |
8338 static int flag_idx = 0; | 8338 static int timeout_flag_idx = 0; |
8339 static int *timeout_flag = &timeout_flags[0]; | 8339 static int *timeout_flag = &timeout_flags[0]; |
8340 | 8340 |
8341 | 8341 |
8342 static void CALLBACK | 8342 static void CALLBACK |
8343 set_flag(void *param, BOOLEAN unused2 UNUSED) | 8343 set_flag(void *param, BOOLEAN unused2 UNUSED) |
8381 volatile int * | 8381 volatile int * |
8382 start_timeout(long msec) | 8382 start_timeout(long msec) |
8383 { | 8383 { |
8384 BOOL ret; | 8384 BOOL ret; |
8385 | 8385 |
8386 timeout_flag = &timeout_flags[flag_idx]; | 8386 timeout_flag = &timeout_flags[timeout_flag_idx]; |
8387 | 8387 |
8388 stop_timeout(); | 8388 stop_timeout(); |
8389 ret = CreateTimerQueueTimer( | 8389 ret = CreateTimerQueueTimer( |
8390 &timer_handle, NULL, set_flag, timeout_flag, | 8390 &timer_handle, NULL, set_flag, timeout_flag, |
8391 (DWORD)msec, 0, WT_EXECUTEDEFAULT); | 8391 (DWORD)msec, 0, WT_EXECUTEDEFAULT); |
8393 { | 8393 { |
8394 semsg(_(e_could_not_set_timeout_str), GetWin32Error()); | 8394 semsg(_(e_could_not_set_timeout_str), GetWin32Error()); |
8395 } | 8395 } |
8396 else | 8396 else |
8397 { | 8397 { |
8398 flag_idx = (flag_idx + 1) % 2; | 8398 timeout_flag_idx = (timeout_flag_idx + 1) % 2; |
8399 timer_active = TRUE; | 8399 timer_active = TRUE; |
8400 *timeout_flag = FALSE; | 8400 *timeout_flag = FALSE; |
8401 } | 8401 } |
8402 return timeout_flag; | 8402 return timeout_flag; |
8403 } | 8403 } |