Closed adaszko closed 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.
Can we use
std::Mutex
to avoid the cloning?