OnceCell and mpsc #6853
Unanswered
Ricardicus
asked this question in
Q&A
Replies: 1 comment
-
If this worked, I think it could make my program more neat. I can get around it by changing my code and passing around the tx, and keeping the rx where it was created, but that means I have to pass this tx in a series of calls. And I just wonder why this approach doesn't work/isn't supported. I also wonder if there are alternative ways I can work to get to the same goal, maybe use different building blocks from tokio. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I want some help.
I need to understand why this does not work, and how I could possible fix it..
Basically, I want one blocking function relying on mpsc that I can export and use.
So I put an mpsc in a static variable, placed in a OnceCell, and one function does the
tx and another one does the blocking rx. For debugging I did a timeout on the rx.
When messages arrive, it seems like the rx side gets stuck. Why is that?
Here comes some code:
The problem I experience is this..
The reading part gets stuck when there is a message. As an example, here I press "ENTER" after a while, and also add some messages that are supposed to be printed:
The idea is to have these functions that I can call from outside of the module that are blocking until I get some input but I get stuck here.
Help would be much appreciated!
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions