You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been going through the locks of my library lavalink-rs, making them live as short as possible, not holding them across awaits, etc... It was all fine and good on 0.11, it compiles fine, and the library doesn't deadlock, even in extreme situations, but updating to 0.12, it no longer compiles. The compiler complains about a value not being Send, which makes no sense.
This is the code that fails to compile, with the error in the following image:
Is the error due to actual poor design? Is this a regression in the library? Or, is this the compiler messing up?
I'm trying to think of ways to solve this by having an alternative design, but the only thing I can think of is refactoring the writer into being a channel instead of a lock, which would be much more work.
The text was updated successfully, but these errors were encountered:
You need to enable the send_guard feature if you want to be able to send a MutexGuard to another thread. The reason this is a separate feature is that it is incompatible with the deadlock detector feature.
The send_guard option is documented in the README. By default, MutexGuard acts like the one in std which is not Send either.
By the way you really shouldn't be holding a MutexGuard across an await since this can cause a deadlock if tokio switches to another task while your suspended task is holding a lock.
I've been going through the locks of my library
lavalink-rs
, making them live as short as possible, not holding them across awaits, etc... It was all fine and good on 0.11, it compiles fine, and the library doesn't deadlock, even in extreme situations, but updating to 0.12, it no longer compiles. The compiler complains about a value not being Send, which makes no sense.This is the code that fails to compile, with the error in the following image:
Is the error due to actual poor design? Is this a regression in the library? Or, is this the compiler messing up?
I'm trying to think of ways to solve this by having an alternative design, but the only thing I can think of is refactoring the writer into being a channel instead of a lock, which would be much more work.
The text was updated successfully, but these errors were encountered: