summaryrefslogtreecommitdiffstats
path: root/src/channel.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-09-16 22:56:03 +0200
committerBram Moolenaar <Bram@vim.org>2019-09-16 22:56:03 +0200
commit0e57dd859ecb1e8a3b91509d2f4343e839340eb8 (patch)
tree50e5f097f3fe10851e7af017cea6cdef35b12402 /src/channel.c
parent69198cb8c08f124729c41a4681f2d142228a9139 (diff)
patch 8.1.2047: cannot check the current statev8.1.2047
Problem: Cannot check the current state. Solution: Add the state() function.
Diffstat (limited to 'src/channel.c')
-rw-r--r--src/channel.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/channel.c b/src/channel.c
index 0dab3be5f4..f40d16ab96 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -3483,6 +3483,7 @@ channel_read(channel_T *channel, ch_part_T part, char *func)
* Read from RAW or NL "channel"/"part". Blocks until there is something to
* read or the timeout expires.
* When "raw" is TRUE don't block waiting on a NL.
+ * Does not trigger timers or handle messages.
* Returns what was read in allocated memory.
* Returns NULL in case of error or timeout.
*/
@@ -3569,6 +3570,17 @@ channel_read_block(
return msg;
}
+static int channel_blocking_wait = 0;
+
+/*
+ * Return TRUE if in a blocking wait that might trigger callbacks.
+ */
+ int
+channel_in_blocking_wait(void)
+{
+ return channel_blocking_wait > 0;
+}
+
/*
* Read one JSON message with ID "id" from "channel"/"part" and store the
* result in "rettv".
@@ -3592,6 +3604,7 @@ channel_read_json_block(
int retval = FAIL;
ch_log(channel, "Blocking read JSON for id %d", id);
+ ++channel_blocking_wait;
if (id >= 0)
channel_add_block_id(chanpart, id);
@@ -3661,6 +3674,7 @@ channel_read_json_block(
}
if (id >= 0)
channel_remove_block_id(chanpart, id);
+ --channel_blocking_wait;
return retval;
}