Skip to content

Commit

Permalink
Use unbounded channel to prevent deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Oct 30, 2024
1 parent 5785ffd commit eba2eb3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ pub enum Message {
TabNext,
TabPrev,
TermEvent(pane_grid::Pane, segmented_button::Entity, TermEvent),
TermEventTx(mpsc::Sender<(pane_grid::Pane, segmented_button::Entity, TermEvent)>),
TermEventTx(mpsc::UnboundedSender<(pane_grid::Pane, segmented_button::Entity, TermEvent)>),
ToggleContextPage(ContextPage),
UpdateDefaultProfile((bool, ProfileId)),
UseBrightBold(bool),
Expand Down Expand Up @@ -411,7 +411,7 @@ pub struct App {
find: bool,
find_search_id: widget::Id,
find_search_value: String,
term_event_tx_opt: Option<mpsc::Sender<(pane_grid::Pane, segmented_button::Entity, TermEvent)>>,
term_event_tx_opt: Option<mpsc::UnboundedSender<(pane_grid::Pane, segmented_button::Entity, TermEvent)>>,
startup_options: Option<tty::Options>,
term_config: term::Config,
color_scheme_errors: Vec<String>,
Expand Down Expand Up @@ -2791,7 +2791,7 @@ impl Application for App {
Subscription::run_with_id(
TypeId::of::<TerminalEventSubscription>(),
stream::channel(100, |mut output| async move {
let (event_tx, mut event_rx) = mpsc::channel(100);
let (event_tx, mut event_rx) = mpsc::unbounded_channel();
output.send(Message::TermEventTx(event_tx)).await.unwrap();

while let Some((pane, entity, event)) = event_rx.recv().await {
Expand Down
6 changes: 3 additions & 3 deletions src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ impl From<Size> for WindowSize {
pub struct EventProxy(
pane_grid::Pane,
segmented_button::Entity,
mpsc::Sender<(pane_grid::Pane, segmented_button::Entity, Event)>,
mpsc::UnboundedSender<(pane_grid::Pane, segmented_button::Entity, Event)>,
);

impl EventListener for EventProxy {
fn send_event(&self, event: Event) {
//TODO: handle error
let _ = self.2.blocking_send((self.0, self.1, event));
let _ = self.2.send((self.0, self.1, event));
}
}

Expand Down Expand Up @@ -221,7 +221,7 @@ impl Terminal {
pub fn new(
pane: pane_grid::Pane,
entity: segmented_button::Entity,
event_tx: mpsc::Sender<(pane_grid::Pane, segmented_button::Entity, Event)>,
event_tx: mpsc::UnboundedSender<(pane_grid::Pane, segmented_button::Entity, Event)>,
config: Config,
options: Options,
app_config: &AppConfig,
Expand Down

0 comments on commit eba2eb3

Please sign in to comment.