@@ -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
@@ -682,6 +685,20 @@ - (BOOL)waitForInput:(int)milliseconds
682685 if ([inputQueue count ]) {
683686 inputReceived = YES ;
684687 } else {
688+ NSTimer *timer = nil ;
689+
690+ // Set interval timer which checks for the events of job and channel
691+ // when there is any pending job or channel.
692+ if (has_any_channel () || has_pending_job ()) {
693+ timer = [NSTimer scheduledTimerWithTimeInterval: 0.1
694+ target: self
695+ selector: @selector (checkForProcessEvents: )
696+ userInfo: nil
697+ repeats: YES ];
698+ [[NSRunLoop currentRunLoop ] addTimer: timer
699+ forMode: NSDefaultRunLoopMode ];
700+ }
701+
685702 // Wait for the specified amount of time, unless 'milliseconds' is
686703 // negative in which case we wait "forever" (1e6 seconds translates to
687704 // approximately 11 days).
@@ -695,6 +712,11 @@ - (BOOL)waitForInput:(int)milliseconds
695712 dt = 0.0 ;
696713 inputReceived = YES ;
697714 }
715+
716+ if (input_available ())
717+ inputReceived = YES ;
718+
719+ [timer invalidate ];
698720 }
699721
700722 // The above calls may have placed messages on the input queue so process
@@ -3004,6 +3026,22 @@ - (void)bevalCallback:(id)sender
30043026}
30053027#endif
30063028
3029+ #ifdef MESSAGE_QUEUE
3030+ - (void )checkForProcessEvents : (NSTimer *)timer
3031+ {
3032+ # ifdef FEAT_TIMERS
3033+ did_add_timer = FALSE ;
3034+ # endif
3035+
3036+ parse_queued_messages ();
3037+
3038+ # ifdef FEAT_TIMERS
3039+ if (did_add_timer || input_available ())
3040+ CFRunLoopStop (CFRunLoopGetCurrent ());
3041+ # endif
3042+ }
3043+ #endif
3044+
30073045@end // MMBackend (Private)
30083046
30093047
0 commit comments