radicle-dev / radicle-client-services

Services backing the Radicle client interfaces.
Apache License 2.0
31 stars 13 forks source link

Fix for: random requests pause for multiple seconds #179

Closed adaszko closed 2 years ago

cloudhead commented 2 years ago

Can we use std::Mutex to avoid the cloning?

adaszko commented 2 years ago

Can we use std::Mutex to avoid the cloning?

No, I don't think that's possible. spawn_blocking() requires its closure argument to be 'static and the temporary lock guard created via ctx.projects.write().await is of a smaller lifetime than 'static'.

What I've done instead to avoid copying is I replaced the call to spawn_blocking() with block_in_place(). It fixes the original problem and avoids copying.