Skip to content

Commit 235364e

Browse files
committed
Check for jobs and channels more often
1 parent 362a5c0 commit 235364e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/MacVim/MMBackend.m

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ - (void)handleGesture:(NSData *)data;
198198
#ifdef FEAT_BEVAL
199199
- (void)bevalCallback:(id)sender;
200200
#endif
201+
#ifdef MESSAGE_QUEUE
202+
- (void)checkForProcessEvents:(NSTimer *)timer;
203+
#endif
201204
@end
202205

203206

@@ -686,6 +689,19 @@ - (BOOL)waitForInput:(int)milliseconds
686689
// negative in which case we wait "forever" (1e6 seconds translates to
687690
// approximately 11 days).
688691
CFTimeInterval dt = (milliseconds >= 0 ? .001*milliseconds : 1e6);
692+
NSTimer *timer = nil;
693+
694+
// Set interval timer which checks for the events of job and channel
695+
// when there is any pending job or channel.
696+
if (dt > 0.1 && (has_any_channel() || has_pending_job())) {
697+
timer = [NSTimer scheduledTimerWithTimeInterval:0.1
698+
target:self
699+
selector:@selector(checkForProcessEvents:)
700+
userInfo:nil
701+
repeats:YES];
702+
[[NSRunLoop currentRunLoop] addTimer:timer
703+
forMode:NSDefaultRunLoopMode];
704+
}
689705

690706
while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, dt, true)
691707
== kCFRunLoopRunHandledSource) {
@@ -695,6 +711,11 @@ - (BOOL)waitForInput:(int)milliseconds
695711
dt = 0.0;
696712
inputReceived = YES;
697713
}
714+
715+
if (input_available())
716+
inputReceived = YES;
717+
718+
[timer invalidate];
698719
}
699720

700721
// The above calls may have placed messages on the input queue so process
@@ -3004,6 +3025,24 @@ - (void)bevalCallback:(id)sender
30043025
}
30053026
#endif
30063027

3028+
#ifdef MESSAGE_QUEUE
3029+
- (void)checkForProcessEvents:(NSTimer *)timer
3030+
{
3031+
# ifdef FEAT_TIMERS
3032+
did_add_timer = FALSE;
3033+
# endif
3034+
3035+
parse_queued_messages();
3036+
3037+
if (input_available()
3038+
# ifdef FEAT_TIMERS
3039+
|| did_add_timer
3040+
# endif
3041+
)
3042+
CFRunLoopStop(CFRunLoopGetCurrent());
3043+
}
3044+
#endif
3045+
30073046
@end // MMBackend (Private)
30083047

30093048

0 commit comments

Comments
 (0)