Mercurial > vim
comparison src/ui.c @ 15404:440e5071f3f8 v8.1.0710
patch 8.1.0710: when using timers may wait for job exit quite long
commit https://github.com/vim/vim/commit/c46af534102c65b43912311d67f55f5049e5ef7a
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 9 22:24:49 2019 +0100
patch 8.1.0710: when using timers may wait for job exit quite long
Problem: When using timers may wait for job exit quite long.
Solution: Return from ui_wait_for_chars_or_timer() when a job or channel
needs to be handled. (Ozaki Kiichi, closes #3783)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 09 Jan 2019 22:30:06 +0100 |
parents | fd9c4b1a71aa |
children | 55ccc2d353bd |
comparison
equal
deleted
inserted
replaced
15403:62e66e6b2c79 | 15404:440e5071f3f8 |
---|---|
203 prof_inchar_exit(); | 203 prof_inchar_exit(); |
204 #endif | 204 #endif |
205 return retval; | 205 return retval; |
206 } | 206 } |
207 | 207 |
208 #if defined(FEAT_TIMERS) || defined(PROT) | 208 #if defined(FEAT_TIMERS) || defined(PROTO) |
209 /* | 209 /* |
210 * Wait for a timer to fire or "wait_func" to return non-zero. | 210 * Wait for a timer to fire or "wait_func" to return non-zero. |
211 * Returns OK when something was read. | 211 * Returns OK when something was read. |
212 * Returns FAIL when it timed out or was interrupted. | 212 * Returns FAIL when it timed out or was interrupted. |
213 */ | 213 */ |
219 int ignore_input) | 219 int ignore_input) |
220 { | 220 { |
221 int due_time; | 221 int due_time; |
222 long remaining = wtime; | 222 long remaining = wtime; |
223 int tb_change_cnt = typebuf.tb_change_cnt; | 223 int tb_change_cnt = typebuf.tb_change_cnt; |
224 | 224 # ifdef FEAT_JOB_CHANNEL |
225 /* When waiting very briefly don't trigger timers. */ | 225 int brief_wait = TRUE; |
226 # endif | |
227 | |
228 // When waiting very briefly don't trigger timers. | |
226 if (wtime >= 0 && wtime < 10L) | 229 if (wtime >= 0 && wtime < 10L) |
227 return wait_func(wtime, NULL, ignore_input); | 230 return wait_func(wtime, NULL, ignore_input); |
228 | 231 |
229 while (wtime < 0 || remaining > 0) | 232 while (wtime < 0 || remaining > 0) |
230 { | 233 { |
231 /* Trigger timers and then get the time in wtime until the next one is | 234 // Trigger timers and then get the time in wtime until the next one is |
232 * due. Wait up to that time. */ | 235 // due. Wait up to that time. |
233 due_time = check_due_timer(); | 236 due_time = check_due_timer(); |
234 if (typebuf.tb_change_cnt != tb_change_cnt) | 237 if (typebuf.tb_change_cnt != tb_change_cnt) |
235 { | 238 { |
236 /* timer may have used feedkeys() */ | 239 /* timer may have used feedkeys() */ |
237 return FAIL; | 240 return FAIL; |
238 } | 241 } |
239 if (due_time <= 0 || (wtime > 0 && due_time > remaining)) | 242 if (due_time <= 0 || (wtime > 0 && due_time > remaining)) |
240 due_time = remaining; | 243 due_time = remaining; |
244 # ifdef FEAT_JOB_CHANNEL | |
245 if ((due_time < 0 || due_time > 10L) | |
246 # ifdef FEAT_GUI | |
247 && !gui.in_use | |
248 # endif | |
249 && (has_pending_job() || channel_any_readahead())) | |
250 { | |
251 // There is a pending job or channel, should return soon in order | |
252 // to handle them ASAP. Do check for input briefly. | |
253 due_time = 10L; | |
254 brief_wait = TRUE; | |
255 } | |
256 # endif | |
241 if (wait_func(due_time, interrupted, ignore_input)) | 257 if (wait_func(due_time, interrupted, ignore_input)) |
242 return OK; | 258 return OK; |
243 if (interrupted != NULL && *interrupted) | 259 if ((interrupted != NULL && *interrupted) |
244 /* Nothing available, but need to return so that side effects get | 260 # ifdef FEAT_JOB_CHANNEL |
245 * handled, such as handling a message on a channel. */ | 261 || brief_wait |
262 # endif | |
263 ) | |
264 // Nothing available, but need to return so that side effects get | |
265 // handled, such as handling a message on a channel. | |
246 return FAIL; | 266 return FAIL; |
247 if (wtime > 0) | 267 if (wtime > 0) |
248 remaining -= due_time; | 268 remaining -= due_time; |
249 } | 269 } |
250 return FAIL; | 270 return FAIL; |
251 } | 271 } |
252 #endif | 272 #endif |
253 | 273 |
254 /* | 274 /* |
255 * return non-zero if a character is available | 275 * Return non-zero if a character is available. |
256 */ | 276 */ |
257 int | 277 int |
258 ui_char_avail(void) | 278 ui_char_avail(void) |
259 { | 279 { |
260 #ifdef FEAT_GUI | 280 #ifdef FEAT_GUI |