diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2016-09-28 12:46:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-28 12:46:03 +0200 |
| commit | 87fa495b21c8afa77c190b30e67c78f237c77216 (patch) | |
| tree | 3b426c3d6ede9c7ea4099c1c798fdac05e662d38 /src/nvim/tui/ui_bridge.h | |
| parent | 22dfe6925d4784cf60d8d9a054abc5066e4b867f (diff) | |
| parent | 7e6a8310b73579b2fa78fb6c410c7101a9f70254 (diff) | |
| download | rneovim-87fa495b21c8afa77c190b30e67c78f237c77216.tar.gz rneovim-87fa495b21c8afa77c190b30e67c78f237c77216.tar.bz2 rneovim-87fa495b21c8afa77c190b30e67c78f237c77216.zip | |
Merge #5395 from justinmk/log
Diffstat (limited to 'src/nvim/tui/ui_bridge.h')
| -rw-r--r-- | src/nvim/tui/ui_bridge.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/nvim/tui/ui_bridge.h b/src/nvim/tui/ui_bridge.h new file mode 100644 index 0000000000..003ed3c2c1 --- /dev/null +++ b/src/nvim/tui/ui_bridge.h @@ -0,0 +1,44 @@ +// Bridge used for communication between a builtin UI thread and nvim core +#ifndef NVIM_TUI_UI_BRIDGE_H +#define NVIM_TUI_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 "tui/ui_bridge.h.generated.h" +#endif +#endif // NVIM_TUI_UI_BRIDGE_H |
