Help with RustOpaque Sending #1296
Answered
by
JustSimplyKyle
JustSimplyKyle
asked this question in
Q&A
-
--> src/api/vanilla.rs:484:29
|
484 | let task = tokio::spawn(async move {
| _____________________________^
485 | | let mut instant = Instant::now();
486 | | let mut prev_bytes = 0.0;
487 | | while !download_complete_clone.load(Ordering::Acquire) {
... |
515 | | sink.close();
516 | | });
| |_____^ future created by async block is not `Send`
|
= help: the trait `std::marker::Sync` is not implemented for `std::sync::mpsc::Receiver<api::State>`
note: captured value is not `Send`
--> src/api/vanilla.rs:505:18
|
505 | dbg!(recv.recv().unwrap());
| ^^^^ has type `flutter_rust_bridge::RustOpaque<std::sync::mpsc::Receiver<api::State>>` which is not `
Send`
note: required by a bound in `tokio::spawn`
--> /home/kyle/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/task/spawn.rs:166:21
|
164 | pub fn spawn<T>(future: T) -> JoinHandle<T::Output>
| ----- required by a bound in this function
165 | where
166 | T: Future + Send + 'static,
| ^^^^ required by this bound in `spawn`I then tried, #[derive(Debug, Copy, Clone)]
pub enum State {
Downlaoding,
Paused,
ForceCancel,
} |
Beta Was this translation helpful? Give feedback.
Answered by
JustSimplyKyle
Jul 28, 2023
Replies: 1 comment 7 replies
-
It may be helpful to provide a bit more details |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That article I did read, it gave me the solution of putting
#[tokio::main(flavor = "current_thread")]to make it work.I've also tried the non async version, which seems not to fix the panic issue
but at the end, I solved the issue!
https://docs.rs/crossbeam/latest/crossbeam/channel/struct.Sender.html
using this crate, I could use a sender that is available to send thru threads safely!(so no weird
.try_unwrap().unwrap()needed.One question, why would using a macro async cause performance issues?