diff options
| author | taitep <taitep@taitep.se> | 2026-01-02 12:44:50 +0100 |
|---|---|---|
| committer | taitep <taitep@taitep.se> | 2026-01-02 12:44:50 +0100 |
| commit | 21fb6cbc8baab44c57c004e9f78904630044499d (patch) | |
| tree | 283c913dd12cddc7e5ffffd938cdbd229692d51b /src | |
| parent | bbc9e0b9ff62c31b6f8da0daff90a883957181f7 (diff) | |
Switch from std::mpsc channels to crossbeam
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.rs | 13 | ||||
| -rw-r--r-- | src/gdb.rs | 13 | ||||
| -rw-r--r-- | src/main.rs | 4 |
3 files changed, 16 insertions, 14 deletions
diff --git a/src/core.rs b/src/core.rs index 30d879a..4a05aa8 100644 --- a/src/core.rs +++ b/src/core.rs @@ -1,10 +1,10 @@ -// 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) // See LICENSE file in the project root for full license text. -use std::{collections::HashSet, sync::mpsc}; +use std::collections::HashSet; use crate::{ core::commands::CoreCmd, @@ -19,13 +19,13 @@ pub struct Core { pub(crate) x_regs: [u64; 32], pub(crate) pc: u64, pub(crate) mem: MemConfig, - command_stream: mpsc::Receiver<CoreCmd>, + command_stream: crossbeam::channel::Receiver<CoreCmd>, } pub mod commands; impl Core { - pub fn new(mem: MemConfig, command_stream: mpsc::Receiver<CoreCmd>) -> Self { + pub fn new(mem: MemConfig, command_stream: crossbeam::channel::Receiver<CoreCmd>) -> Self { Self { x_regs: [0; 32], pc: 0, @@ -103,7 +103,10 @@ impl Core { }; } - fn debug_loop(&mut self, dbg_stream: mpsc::Receiver<gdb::DebugCommand>) -> anyhow::Result<()> { + fn debug_loop( + &mut self, + dbg_stream: crossbeam::channel::Receiver<gdb::DebugCommand>, + ) -> anyhow::Result<()> { let mut breakpoints = HashSet::new(); loop { @@ -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<DebugCommand>); +pub struct DebugStream(pub(crate) crossbeam::channel::Receiver<DebugCommand>); #[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<CoreCmd>) { +pub fn run_stub(cmd_sender: crossbeam::channel::Sender<CoreCmd>) { 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<CoreCmd>) { fn handle_gdb_connection( gdb_stream: TcpStream, - dbg_tx: mpsc::Sender<DebugCommand>, + dbg_tx: crossbeam::channel::Sender<DebugCommand>, ) -> io::Result<()> { eprintln!("gdb connected"); let mut reader = io::BufReader::new(gdb_stream.try_clone()?); @@ -152,7 +151,7 @@ fn read_rsp_packet<R: BufRead>(reader: &mut R) -> io::Result<String> { fn handle_packet<W: Write, R: BufRead>( packet: &str, writer: &mut W, - dbg_tx: &mpsc::Sender<DebugCommand>, + dbg_tx: &crossbeam::channel::Sender<DebugCommand>, reader: &mut R, ) -> io::Result<()> { writer.write_all(b"+")?; diff --git a/src/main.rs b/src/main.rs index 4e02745..a9b8672 100644 --- a/src/main.rs +++ b/src/main.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) @@ -48,7 +48,7 @@ fn main() -> Result<()> { mmio_root, }; - let (cmd_sender, cmd_reciever) = std::sync::mpsc::channel(); + let (cmd_sender, cmd_reciever) = crossbeam::channel::bounded(16); gdb::run_stub(cmd_sender.clone()); |
