Skip to content

Commit c847b6a

Browse files
committed
Implement drop for IoThreads
1 parent 90105c7 commit c847b6a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/connection.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use dap::server::{ServerReader, ServerWriter};
1414
pub struct Connection {
1515
inbound_rx: mpsc::Receiver<Request>,
1616
outbound_tx: mpsc::Sender<Sendable>,
17-
io_threads: IoThreads,
17+
_io_threads: IoThreads,
1818
}
1919

2020
struct IoThreads {
@@ -38,9 +38,11 @@ impl Connection {
3838
let (inbound_tx, inbound_rx) = mpsc::channel::<Request>();
3939
let (outbound_tx, outbound_rx) = mpsc::channel::<Sendable>();
4040

41-
let io_threads = IoThreads::spawn(server_reader, server_writer, inbound_tx, outbound_rx);
42-
43-
Ok(Self { inbound_rx, outbound_tx, io_threads })
41+
Ok(Self {
42+
inbound_rx,
43+
outbound_tx,
44+
_io_threads: IoThreads::spawn(server_reader, server_writer, inbound_tx, outbound_rx),
45+
})
4446
}
4547

4648
pub fn next_request(&self) -> Result<Request> {
@@ -80,10 +82,10 @@ impl IoThreads {
8082
}
8183
}
8284

83-
impl Drop for Connection {
85+
impl Drop for IoThreads {
8486
fn drop(&mut self) {
85-
self.io_threads.reader.take().map(|h| h.join());
86-
self.io_threads.writer.take().map(|h| h.join());
87+
self.reader.take().map(|h| h.join());
88+
self.writer.take().map(|h| h.join());
8789
}
8890
}
8991

0 commit comments

Comments
 (0)