Okay, then I will not feel bad using it
I do remember your posts here. For now, simply requiring Unpin
works fine, except it's a bit verbose.
Yeah thanks. The next subsection also explains how to make the methods non-threadsafe by using #[async_trait(?Send)]
. I had to actually use this because I need my async method to hold an RwLockReadGuard
and that is !Send
. However, I ran into the problems that you already pointed out:
The only way out was to use tokio::task::spawn_local
, which β in turn β required me to create a tokio::task::LocalSet
in my program's main function.
So async works, but I lost multithreading support.
Is it somehow possible to hold an RwLockReadGuard
or MutexGuard
in an async function or method that gets spawn
'ed? β¦ Nevermind, while writing this, I just found the answer: Yes. Tokio provides several Send
'able synchronization locks/guards in its tokio::sync
module. That should allow me to make all futures Send
again despite using locks/guards. Will try that tomorrow, but wanted to share this, in case any other people have problems with locks and async functions.
tokio::sync::MutexGuard
A handle to a heldMutex
. The guard can be held across any.await
point as it isSend
.
Thanks for helping and encouraging me to keep on!