Compare commits
No commits in common. "f60d986caca5542c27a6c7ba813ee2b7fe8e247c" and "cd3cb3aeb865bddd61d5808b898530f7e2eacf87" have entirely different histories.
f60d986cac
...
cd3cb3aeb8
3 changed files with 6 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -233,6 +233,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||||
name = "audrey"
|
name = "audrey"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"async-channel",
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|
|
@ -5,6 +5,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] }
|
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] }
|
||||||
|
async-channel = "2.3.1"
|
||||||
bytes = "1.8.0"
|
bytes = "1.8.0"
|
||||||
chrono = { version = "0.4.38", features = ["serde", "std"], default-features = false }
|
chrono = { version = "0.4.38", features = ["serde", "std"], default-features = false }
|
||||||
color-thief = "0.2.2"
|
color-thief = "0.2.2"
|
||||||
|
|
|
@ -153,7 +153,8 @@ impl Client {
|
||||||
&self,
|
&self,
|
||||||
request: reqwest_middleware::RequestBuilder,
|
request: reqwest_middleware::RequestBuilder,
|
||||||
) -> Result<ByteResponse, Error> {
|
) -> Result<ByteResponse, Error> {
|
||||||
let (sender, receiver) = tokio::sync::oneshot::channel();
|
// FIXME: is an entire channel per request overkill? maybe pool them?
|
||||||
|
let (sender, receiver) = async_channel::bounded(1);
|
||||||
|
|
||||||
// let tokio take care of the request + further json parsing
|
// let tokio take care of the request + further json parsing
|
||||||
// this is because reqwest doesn't like the glib main loop
|
// this is because reqwest doesn't like the glib main loop
|
||||||
|
@ -197,10 +198,11 @@ impl Client {
|
||||||
// note that in general its fine not to cancel the tokio task when its corresponding
|
// 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
|
// mainloop task is dropped, since eg for song thumbnails there's already a semaphore
|
||||||
// limiting concurrent requests
|
// limiting concurrent requests
|
||||||
let _ = sender.send(perform(future.await).await);
|
let _ = sender.send(perform(future.await).await).await;
|
||||||
});
|
});
|
||||||
|
|
||||||
receiver
|
receiver
|
||||||
|
.recv()
|
||||||
.await
|
.await
|
||||||
.map_err(|_| Error::OtherError("failed to receive response from tokio loop"))?
|
.map_err(|_| Error::OtherError("failed to receive response from tokio loop"))?
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue