-
Hello, I would like to understand what is the best practice for running some asynchronous tasks on a dedicated thread, please. My application is using tokio broadcast channels to notify for internal events. Some event receivers are fine to run concurrently with other tasks managed by tokio runtime. However I would like to have a dedicated thread for a receiver which will log events to some place. The objective here is to minimize lagging. Let 's see options I have (not warranted to compile, just some thoughts): Option 1:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Due to your use of |
Beta Was this translation helpful? Give feedback.
Due to your use of
recv
inside the thread, you should not usespawn_blocking
. Usestd::thread::spawn
instead. You can read why here. As forblock_on
, use the one onHandle
. See also this post.