diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-10-13 15:21:33 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-10-13 16:05:06 +0200 |
commit | c9b9f052cc3c6e8b7a999f3039cd4ace16094be2 (patch) | |
tree | a6502f6253b9f1b2dcadf45396344fe553b054ee /src/nvim/ui_bridge.h | |
parent | 294c0ba0149950696aec1da6f0af549a0662fd08 (diff) | |
download | rneovim-c9b9f052cc3c6e8b7a999f3039cd4ace16094be2.tar.gz rneovim-c9b9f052cc3c6e8b7a999f3039cd4ace16094be2.tar.bz2 rneovim-c9b9f052cc3c6e8b7a999f3039cd4ace16094be2.zip |
Revert "tui: Move ui_bridge module to tui/ namespace."
ui_bridge.c is useful for libnvim consumers, not just the built-in TUI.
This reverts commit beb2e4f095583af09ebe9c66e3bf453b61511f23.
Diffstat (limited to 'src/nvim/ui_bridge.h')
-rw-r--r-- | src/nvim/ui_bridge.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/nvim/ui_bridge.h b/src/nvim/ui_bridge.h new file mode 100644 index 0000000000..9e4bf9f2a7 --- /dev/null +++ b/src/nvim/ui_bridge.h @@ -0,0 +1,45 @@ +// Bridge for communication between a UI thread and nvim core. +// Used by the built-in TUI and external libnvim-based UIs. +#ifndef NVIM_UI_BRIDGE_H +#define NVIM_UI_BRIDGE_H + +#include <uv.h> + +#include "nvim/ui.h" +#include "nvim/event/defs.h" + +typedef struct ui_bridge_data UIBridgeData; +typedef void(*ui_main_fn)(UIBridgeData *bridge, UI *ui); +struct ui_bridge_data { + UI bridge; // actual UI passed to ui_attach + UI *ui; // UI pointer that will have its callback called in + // another thread + event_scheduler scheduler; + uv_thread_t ui_thread; + ui_main_fn ui_main; + uv_mutex_t mutex; + uv_cond_t cond; + // When the UI thread is called, the main thread will suspend until + // the call returns. This flag is used as a condition for the main + // thread to continue. + bool ready; + // When a stop request is sent from the main thread, it must wait until the UI + // thread finishes handling all events. This flag is set by the UI thread as a + // signal that it will no longer send messages to the main thread. + bool stopped; +}; + +#define CONTINUE(b) \ + do { \ + UIBridgeData *d = (UIBridgeData *)b; \ + uv_mutex_lock(&d->mutex); \ + d->ready = true; \ + uv_cond_signal(&d->cond); \ + uv_mutex_unlock(&d->mutex); \ + } while (0) + + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "ui_bridge.h.generated.h" +#endif +#endif // NVIM_UI_BRIDGE_H |