Clean up tokio::sync::mpsc imports

macos-click-through
mforsb 3 years ago committed by Keith Simmons
parent e343c64d4e
commit 8779a76fb0

@ -14,7 +14,7 @@ use nvim_rs::UiAttachOptions;
use rmpv::Value; use rmpv::Value;
use tokio::process::Command; use tokio::process::Command;
use tokio::runtime::Runtime; use tokio::runtime::Runtime;
use tokio::sync::mpsc; use tokio::sync::mpsc::UnboundedReceiver;
use crate::channel_utils::*; use crate::channel_utils::*;
use crate::settings::*; use crate::settings::*;
@ -156,7 +156,7 @@ fn connection_mode() -> ConnectionMode {
async fn start_neovim_runtime( async fn start_neovim_runtime(
ui_command_sender: LoggingTx<UiCommand>, ui_command_sender: LoggingTx<UiCommand>,
mut ui_command_receiver: mpsc::UnboundedReceiver<UiCommand>, mut ui_command_receiver: UnboundedReceiver<UiCommand>,
redraw_event_sender: LoggingTx<RedrawEvent>, redraw_event_sender: LoggingTx<RedrawEvent>,
running: Arc<AtomicBool>, running: Arc<AtomicBool>,
) { ) {
@ -317,7 +317,7 @@ pub struct Bridge {
pub fn start_bridge( pub fn start_bridge(
ui_command_sender: LoggingTx<UiCommand>, ui_command_sender: LoggingTx<UiCommand>,
ui_command_receiver: mpsc::UnboundedReceiver<UiCommand>, ui_command_receiver: UnboundedReceiver<UiCommand>,
redraw_event_sender: LoggingTx<RedrawEvent>, redraw_event_sender: LoggingTx<RedrawEvent>,
running: Arc<AtomicBool>, running: Arc<AtomicBool>,
) -> Bridge { ) -> Bridge {

@ -2,7 +2,7 @@ use std::fmt::Debug;
use std::sync::mpsc::{SendError, Sender}; use std::sync::mpsc::{SendError, Sender};
use log::trace; use log::trace;
use tokio::sync::mpsc; use tokio::sync::mpsc::{error::SendError as TokioSendError, UnboundedSender};
#[derive(Clone)] #[derive(Clone)]
pub struct LoggingSender<T> pub struct LoggingSender<T>
@ -35,7 +35,7 @@ pub struct LoggingTx<T>
where where
T: Debug, T: Debug,
{ {
tx: mpsc::UnboundedSender<T>, tx: UnboundedSender<T>,
channel_name: String, channel_name: String,
} }
@ -43,11 +43,11 @@ impl<T> LoggingTx<T>
where where
T: Debug, T: Debug,
{ {
pub fn attach(tx: mpsc::UnboundedSender<T>, channel_name: String) -> Self { pub fn attach(tx: UnboundedSender<T>, channel_name: String) -> Self {
Self { tx, channel_name } Self { tx, channel_name }
} }
pub fn send(&self, message: T) -> Result<(), mpsc::error::SendError<T>> { pub fn send(&self, message: T) -> Result<(), TokioSendError<T>> {
trace!("{} {:?}", self.channel_name, &message); trace!("{} {:?}", self.channel_name, &message);
self.tx.send(message) self.tx.send(message)
} }

@ -9,7 +9,7 @@ use std::sync::Arc;
use std::thread; use std::thread;
use log::{error, trace}; use log::{error, trace};
use tokio::sync::mpsc; use tokio::sync::mpsc::UnboundedReceiver;
use crate::bridge::{EditorMode, GuiOption, RedrawEvent, WindowAnchor}; use crate::bridge::{EditorMode, GuiOption, RedrawEvent, WindowAnchor};
use crate::channel_utils::*; use crate::channel_utils::*;
@ -440,7 +440,7 @@ impl Editor {
} }
pub fn start_editor( pub fn start_editor(
mut redraw_event_receiver: mpsc::UnboundedReceiver<RedrawEvent>, mut redraw_event_receiver: UnboundedReceiver<RedrawEvent>,
batched_draw_command_sender: LoggingSender<Vec<DrawCommand>>, batched_draw_command_sender: LoggingSender<Vec<DrawCommand>>,
window_command_sender: LoggingSender<WindowCommand>, window_command_sender: LoggingSender<WindowCommand>,
) { ) {

@ -31,7 +31,7 @@ extern crate lazy_static;
use std::sync::{atomic::AtomicBool, mpsc::channel, Arc}; use std::sync::{atomic::AtomicBool, mpsc::channel, Arc};
use tokio::sync::mpsc; use tokio::sync::mpsc::unbounded_channel;
use bridge::start_bridge; use bridge::start_bridge;
use cmd_line::CmdLineSettings; use cmd_line::CmdLineSettings;
@ -136,7 +136,7 @@ fn main() {
let running = Arc::new(AtomicBool::new(true)); let running = Arc::new(AtomicBool::new(true));
let (redraw_event_sender, redraw_event_receiver) = mpsc::unbounded_channel(); let (redraw_event_sender, redraw_event_receiver) = unbounded_channel();
let logging_redraw_event_sender = let logging_redraw_event_sender =
LoggingTx::attach(redraw_event_sender, "redraw_event".to_owned()); LoggingTx::attach(redraw_event_sender, "redraw_event".to_owned());
@ -146,7 +146,7 @@ fn main() {
"batched_draw_command".to_owned(), "batched_draw_command".to_owned(),
); );
let (ui_command_sender, ui_command_receiver) = mpsc::unbounded_channel(); let (ui_command_sender, ui_command_receiver) = unbounded_channel();
let logging_ui_command_sender = LoggingTx::attach(ui_command_sender, "ui_command".to_owned()); let logging_ui_command_sender = LoggingTx::attach(ui_command_sender, "ui_command".to_owned());
let (window_command_sender, window_command_receiver) = channel(); let (window_command_sender, window_command_receiver) = channel();

Loading…
Cancel
Save