ExidexE
Denoβ€’3y agoβ€’
11 replies
Exidex

How do I enqueue_microtask from other thread

so Isolate.enqueue_microtask is obviously not send/sync so I think the only option is to use std::sync::mpsc::channel and use Receiver.try_recv to get the values from Sender on other thread. The problem is that I am being a rust newbie don't know how to combine them on the single thread or if it actually possible. I somehow need to wake up the runtime when the Sender actually sends the value, I think I can wrap try_recv with poll_fn and use something like tokio's select! macro but that also doesn't seem to fit my problem because I need to be able to restart run_event_loop to process any new microtasks. Any pointers?
Was this page helpful?