diff --git a/Cargo.toml b/Cargo.toml index 0d5250e..27af971 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,6 @@ nvim-rs = { git = "https://github.com/KillTheMule/nvim-rs", branch = "master", f tokio = { version = "1.1.1", features = ["full"] } tokio-util = "0.6.7" async-trait = "0.1.18" -crossfire = "0.1" lazy_static = "1.4.0" unicode-segmentation = "1.6.0" log = "0.4.8" diff --git a/src/bridge/mod.rs b/src/bridge/mod.rs index 773cf60..8db80b9 100644 --- a/src/bridge/mod.rs +++ b/src/bridge/mod.rs @@ -9,12 +9,12 @@ use std::process::Stdio; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -use crossfire::mpsc::RxUnbounded; use log::{error, info, warn}; use nvim_rs::UiAttachOptions; use rmpv::Value; use tokio::process::Command; use tokio::runtime::Runtime; +use tokio::sync::mpsc; use crate::channel_utils::*; use crate::settings::*; @@ -157,7 +157,7 @@ fn connection_mode() -> ConnectionMode { async fn start_neovim_runtime( ui_command_sender: LoggingTx, - ui_command_receiver: RxUnbounded, + mut ui_command_receiver: mpsc::UnboundedReceiver, redraw_event_sender: LoggingTx, running: Arc, ) { @@ -297,13 +297,13 @@ async fn start_neovim_runtime( } match ui_command_receiver.recv().await { - Ok(ui_command) => { + Some(ui_command) => { let input_nvim = input_nvim.clone(); tokio::spawn(async move { ui_command.execute(&input_nvim).await; }); } - Err(_) => { + None => { ui_command_running.store(false, Ordering::Relaxed); break; } @@ -321,7 +321,7 @@ pub struct Bridge { pub fn start_bridge( ui_command_sender: LoggingTx, - ui_command_receiver: RxUnbounded, + ui_command_receiver: mpsc::UnboundedReceiver, redraw_event_sender: LoggingTx, running: Arc, ) -> Bridge { diff --git a/src/channel_utils.rs b/src/channel_utils.rs index edb8807..4a1466f 100644 --- a/src/channel_utils.rs +++ b/src/channel_utils.rs @@ -1,8 +1,8 @@ use std::fmt::Debug; use std::sync::mpsc::{SendError, Sender}; -use crossfire::mpsc::{SendError as TxError, TxUnbounded}; use log::trace; +use tokio::sync::mpsc; #[derive(Clone)] pub struct LoggingSender @@ -35,7 +35,7 @@ pub struct LoggingTx where T: Debug, { - tx: TxUnbounded, + tx: mpsc::UnboundedSender, channel_name: String, } @@ -43,11 +43,11 @@ impl LoggingTx where T: Debug, { - pub fn attach(tx: TxUnbounded, channel_name: String) -> Self { + pub fn attach(tx: mpsc::UnboundedSender, channel_name: String) -> Self { Self { tx, channel_name } } - pub fn send(&self, message: T) -> Result<(), TxError> { + pub fn send(&self, message: T) -> Result<(), mpsc::error::SendError> { trace!("{} {:?}", self.channel_name, &message); self.tx.send(message) } diff --git a/src/editor/mod.rs b/src/editor/mod.rs index 9e1362e..1f20e0c 100644 --- a/src/editor/mod.rs +++ b/src/editor/mod.rs @@ -8,8 +8,8 @@ use std::collections::HashMap; use std::sync::Arc; use std::thread; -use crossfire::mpsc::RxUnbounded; use log::{error, trace}; +use tokio::sync::mpsc; use crate::bridge::{EditorMode, GuiOption, RedrawEvent, WindowAnchor}; use crate::channel_utils::*; @@ -440,14 +440,14 @@ impl Editor { } pub fn start_editor( - redraw_event_receiver: RxUnbounded, + mut redraw_event_receiver: mpsc::UnboundedReceiver, batched_draw_command_sender: LoggingSender>, window_command_sender: LoggingSender, ) { thread::spawn(move || { let mut editor = Editor::new(batched_draw_command_sender, window_command_sender); - while let Ok(redraw_event) = redraw_event_receiver.recv_blocking() { + while let Some(redraw_event) = redraw_event_receiver.blocking_recv() { editor.handle_redraw_event(redraw_event); } }); diff --git a/src/main.rs b/src/main.rs index 00cc727..507491a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,7 +31,7 @@ extern crate lazy_static; use std::sync::{atomic::AtomicBool, mpsc::channel, Arc}; -use crossfire::mpsc::unbounded_future; +use tokio::sync::mpsc; use bridge::start_bridge; use cmd_line::CmdLineSettings; @@ -136,7 +136,7 @@ fn main() { let running = Arc::new(AtomicBool::new(true)); - let (redraw_event_sender, redraw_event_receiver) = unbounded_future(); + let (redraw_event_sender, redraw_event_receiver) = mpsc::unbounded_channel(); let logging_redraw_event_sender = LoggingTx::attach(redraw_event_sender, "redraw_event".to_owned()); @@ -146,7 +146,7 @@ fn main() { "batched_draw_command".to_owned(), ); - let (ui_command_sender, ui_command_receiver) = unbounded_future(); + let (ui_command_sender, ui_command_receiver) = mpsc::unbounded_channel(); let logging_ui_command_sender = LoggingTx::attach(ui_command_sender, "ui_command".to_owned()); let (window_command_sender, window_command_receiver) = channel();