From 215dc4cd13251fcfcf0df070f68dc0c307bc296b Mon Sep 17 00:00:00 2001 From: Erica Z Date: Sat, 23 Nov 2024 13:49:23 +0100 Subject: [PATCH] use tokio oneshot channel --- src/subsonic.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/subsonic.rs b/src/subsonic.rs index b79137e..c8ec249 100644 --- a/src/subsonic.rs +++ b/src/subsonic.rs @@ -153,8 +153,7 @@ impl Client { &self, request: reqwest_middleware::RequestBuilder, ) -> Result { - // FIXME: is an entire channel per request overkill? maybe pool them? - let (sender, receiver) = async_channel::bounded(1); + let (sender, receiver) = tokio::sync::oneshot::channel(); // let tokio take care of the request + further json parsing // this is because reqwest doesn't like the glib main loop @@ -198,11 +197,10 @@ impl Client { // note that in general its fine not to cancel the tokio task when its corresponding // mainloop task is dropped, since eg for song thumbnails there's already a semaphore // limiting concurrent requests - let _ = sender.send(perform(future.await).await).await; + let _ = sender.send(perform(future.await).await); }); receiver - .recv() .await .map_err(|_| Error::OtherError("failed to receive response from tokio loop"))? }