From 21fb6cbc8baab44c57c004e9f78904630044499d Mon Sep 17 00:00:00 2001 From: taitep Date: Fri, 2 Jan 2026 12:44:50 +0100 Subject: Switch from std::mpsc channels to crossbeam --- src/gdb.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/gdb.rs') diff --git a/src/gdb.rs b/src/gdb.rs index d781a6a..7c1fcd8 100644 --- a/src/gdb.rs +++ b/src/gdb.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2025 taitep +// Copyright (c) 2025-2026 taitep // SPDX-License-Identifier: BSD-2-Clause // // This file is part of TRVE (https://gitea.taitep.se/taitep/trve) @@ -7,7 +7,6 @@ use std::{ io::{self, BufRead, ErrorKind, Write}, net::{TcpListener, TcpStream}, - sync::mpsc, }; use crate::{ @@ -29,7 +28,7 @@ pub(crate) enum DebugCommand { ExitDebugMode, } -pub struct DebugStream(pub(crate) mpsc::Receiver); +pub struct DebugStream(pub(crate) crossbeam::channel::Receiver); #[derive(Clone, Copy, Debug)] pub(crate) enum StopReason { @@ -68,13 +67,13 @@ pub(crate) struct RegsResponse { pub pc: u64, } -pub fn run_stub(cmd_sender: mpsc::Sender) { +pub fn run_stub(cmd_sender: crossbeam::channel::Sender) { std::thread::spawn(move || { let listener = TcpListener::bind("127.0.0.1:1234").expect("couldnt start tcp listener"); for stream_res in listener.incoming() { if let Ok(stream) = stream_res { - let (dbg_tx, dbg_rx) = mpsc::channel(); + let (dbg_tx, dbg_rx) = crossbeam::channel::bounded(16); stream .set_nonblocking(true) @@ -92,7 +91,7 @@ pub fn run_stub(cmd_sender: mpsc::Sender) { fn handle_gdb_connection( gdb_stream: TcpStream, - dbg_tx: mpsc::Sender, + dbg_tx: crossbeam::channel::Sender, ) -> io::Result<()> { eprintln!("gdb connected"); let mut reader = io::BufReader::new(gdb_stream.try_clone()?); @@ -152,7 +151,7 @@ fn read_rsp_packet(reader: &mut R) -> io::Result { fn handle_packet( packet: &str, writer: &mut W, - dbg_tx: &mpsc::Sender, + dbg_tx: &crossbeam::channel::Sender, reader: &mut R, ) -> io::Result<()> { writer.write_all(b"+")?; -- cgit v1.2.3