summaryrefslogtreecommitdiffstats
path: root/zellij-client/src
diff options
context:
space:
mode:
authorkxt <ktamas@fastmail.fm>2021-05-27 16:28:28 +0200
committerGitHub <noreply@github.com>2021-05-27 16:28:28 +0200
commit0c0355dbc6e0159a72b0f55c7aabb83d76c2312a (patch)
treeeb09715c31950f918efe54bd189af65b5b2fdab0 /zellij-client/src
parent9bdb40b4c644c6a3a061dd0cc4683fc92d504201 (diff)
refactors for #525 (#534)
* refactor(fakes): clean up add_terminal_input * refactor(fakes): append whole buf to output_buffer in FakeStdoutWriter::write * refactor(fakes): append whole buf to output_buffer in FakeInputOutput::write_to_tty_stdin * fix(fakes): allow partial reads in read_from_tty_stdout This patch fixes two bugs in read_from_tty_stdout: * if there was a partial read (ie. `bytes.read_position` is not 0 but less than `bytes.content.len()`), subsequent calls to would fill `buf` starting at index `bytes.read_position` instead of 0, leaving range 0..`bytes.read_position` untouched. * if `buf` was smaller than `bytes.content.len()`, a panic would occur. * refactor(channels): use crossbeam instead of mpsc This patch replaces mpsc with crossbeam channels because crossbeam supports selecting on multiple channels which will be necessary in a subsequent patch. * refactor(threadbus): allow multiple receivers in Bus This patch changes Bus to use multiple receivers. Method `recv` returns data from all of them. This will be used in a subsequent patch for receiving from bounded and unbounded queues at the same time. * refactor(channels): remove SenderType enum This enum has only one variant, so the entire enum can be replaced with the innards of said variant. * refactor(channels): remove Send+Sync trait implementations The implementation of these traits is not necessary, as SenderWithContext is automatically Send and Sync for every T and ErrorContext that's Send and Sync.
Diffstat (limited to 'zellij-client/src')
-rw-r--r--zellij-client/src/lib.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs
index f3b0f11d3..3817e7908 100644
--- a/zellij-client/src/lib.rs
+++ b/zellij-client/src/lib.rs
@@ -7,7 +7,6 @@ use std::env::current_exe;
use std::io::{self, Write};
use std::path::Path;
use std::process::Command;
-use std::sync::mpsc;
use std::thread;
use crate::{
@@ -16,7 +15,7 @@ use crate::{
};
use zellij_utils::cli::CliArgs;
use zellij_utils::{
- channels::{SenderType, SenderWithContext, SyncChannelWithContext},
+ channels::{self, ChannelWithContext, SenderWithContext},
consts::{SESSION_NAME, ZELLIJ_IPC_PIPE},
errors::{ClientContext, ContextType, ErrorInstruction},
input::{actions::Action, config::Config, options::Options},
@@ -149,11 +148,10 @@ pub fn start_client(
.write(bracketed_paste.as_bytes())
.unwrap();
- let (send_client_instructions, receive_client_instructions): SyncChannelWithContext<
+ let (send_client_instructions, receive_client_instructions): ChannelWithContext<
ClientInstruction,
- > = mpsc::sync_channel(50);
- let send_client_instructions =
- SenderWithContext::new(SenderType::SyncSender(send_client_instructions));
+ > = channels::bounded(50);
+ let send_client_instructions = SenderWithContext::new(send_client_instructions);
#[cfg(not(any(feature = "test", test)))]
std::panic::set_hook({