Merge pull request #330 from macvim-dev/fix/job_fail

Use global queue in order to catch read event from channel
This commit is contained in:
Kazuki Sakamoto
2016-08-19 20:46:59 -07:00
committed by GitHub
2 changed files with 20 additions and 9 deletions
+18 -5
View File
@@ -2257,16 +2257,28 @@ static int vimModMaskToEventModifierFlags(int mods)
// -- Channel Support ------------------------------------------------------
static NSMutableSet *MMChannels;
void *
gui_macvim_add_channel(channel_T *channel, int part)
{
if (!MMChannels)
MMChannels = [NSMutableSet new];
int fd = channel->ch_part[part].ch_fd;
dispatch_queue_t q =
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_source_t s =
dispatch_source_create(DISPATCH_SOURCE_TYPE_READ,
channel->ch_part[part].ch_fd,
0,
dispatch_get_main_queue());
dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, fd, 0, q);
[MMChannels addObject:s];
dispatch_source_set_event_handler(s, ^{
channel_read(channel, part, "gui_macvim_add_channel");
dispatch_suspend(s);
dispatch_async(dispatch_get_main_queue(), ^{
if ([MMChannels containsObject:s]) {
channel_read(channel, part, "gui_macvim_add_channel");
dispatch_resume(s);
}
});
});
dispatch_resume(s);
return s;
@@ -2276,6 +2288,7 @@ gui_macvim_add_channel(channel_T *channel, int part)
gui_macvim_remove_channel(void *cookie)
{
dispatch_source_t s = (dispatch_source_t)cookie;
[MMChannels removeObject:s];
dispatch_source_cancel(s);
dispatch_release(s);
}
+2 -4
View File
@@ -599,11 +599,9 @@ channel_gui_register_one(channel_T *channel, int part)
# endif
# else
# ifdef FEAT_GUI_MACVIM
/* Tell Core Foundation we are interested in being called when there
* is input on the editor connection socket. */
if (channel->ch_part[part].ch_inputHandler == 0)
channel->ch_part[part].ch_inputHandler = gui_macvim_add_channel(
channel, part);
channel->ch_part[part].ch_inputHandler =
gui_macvim_add_channel(channel, part);
# endif
# endif
# endif