diff options
| author | Kunal Mohan <kunalmohan99@gmail.com> | 2021-02-13 15:50:56 +0530 |
|---|---|---|
| committer | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-04 20:47:49 +0530 |
| commit | aef52b06907e9ce7a933b33112ec69ecc4def507 (patch) | |
| tree | 936515cc3af1d07c78daecaa1d3ee16588a9780a /src/common | |
| parent | Got things working! But we are loosing data in transmission :( PS: There are ... (diff) | |
| download | sl0ppij-aef52b06907e9ce7a933b33112ec69ecc4def507.tar.gz sl0ppij-aef52b06907e9ce7a933b33112ec69ecc4def507.tar.xz sl0ppij-aef52b06907e9ce7a933b33112ec69ecc4def507.zip | |
Use interprocess crate, BufReader and BufWriter
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/mod.rs | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/common/mod.rs b/src/common/mod.rs index 62d7e702..4e0eeec1 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -9,19 +9,21 @@ pub mod setup; pub mod utils; pub mod wasm_vm; -use std::io::Write; -use std::os::unix::net::UnixStream; +use std::io::{BufWriter, Write}; use std::path::{Path, PathBuf}; use std::sync::mpsc; use std::thread; use std::{collections::HashMap, fs}; -use std::{ - collections::HashSet, - env, - io::Write, - str::FromStr, - sync::{Arc, Mutex}, -}; + +use crate::panes::PaneId; +use directories_next::ProjectDirs; +use input::handler::InputMode; +use interprocess::local_socket::LocalSocketStream; +use serde::{Deserialize, Serialize}; +use termion::input::TermRead; +use wasm_vm::PluginEnv; +use wasmer::{ChainableNamedResolver, Instance, Module, Store, Value}; +use wasmer_wasi::{Pipe, WasiState}; use crate::cli::CliArgs; use crate::layout::Layout; @@ -125,14 +127,14 @@ thread_local!( ); pub struct IpcSenderWithContext { err_ctx: ErrorContext, - sender: UnixStream, + sender: BufWriter<LocalSocketStream>, } impl IpcSenderWithContext { pub fn new() -> Self { Self { err_ctx: ErrorContext::new(), - sender: UnixStream::connect(ZELLIJ_IPC_PIPE).unwrap(), + sender: BufWriter::new(LocalSocketStream::connect(ZELLIJ_IPC_PIPE).unwrap()), } } @@ -143,7 +145,9 @@ impl IpcSenderWithContext { pub fn send(&mut self, msg: ApiCommand) -> std::io::Result<()> { eprintln!("IpcSender sent {:?}", msg); let command = bincode::serialize(&(self.err_ctx, msg)).unwrap(); - self.sender.write_all(&command) + let x = self.sender.write_all(&command); + self.sender.flush(); + x } } @@ -151,7 +155,7 @@ impl std::clone::Clone for IpcSenderWithContext { fn clone(&self) -> Self { Self { err_ctx: self.err_ctx, - sender: UnixStream::connect(ZELLIJ_IPC_PIPE).unwrap(), + sender: BufWriter::new(LocalSocketStream::connect(ZELLIJ_IPC_PIPE).unwrap()), } } } @@ -561,8 +565,8 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs, config: Config) { break; } AppInstruction::Error(backtrace) => { - //let _ = send_server_instructions.send(ApiCommand::Quit); - //let _ = ipc_thread.join(); + let _ = send_server_instructions.send(ApiCommand::Quit); + let _ = ipc_thread.join(); //IpcSenderWithContext::new().send(ApiCommand::Quit); let _ = send_screen_instructions.send(ScreenInstruction::Quit); let _ = screen_thread.join(); @@ -591,7 +595,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs, config: Config) { } let _ = send_server_instructions.send(ApiCommand::Quit); - //let _ = ipc_thread.join().unwrap(); + let _ = ipc_thread.join().unwrap(); //IpcSenderWithContext::new().send(ApiCommand::Quit); let _ = send_screen_instructions.send(ScreenInstruction::Quit); screen_thread.join().unwrap(); |
