Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to avoid 100% cpu usage for reading #32

Open
maxgorovenko opened this issue Oct 20, 2021 · 1 comment
Open

Try to avoid 100% cpu usage for reading #32

maxgorovenko opened this issue Oct 20, 2021 · 1 comment

Comments

@maxgorovenko
Copy link

I'm trying to make a data bus with this lib and have a problem. When thread begins reading from stream, it uses 100% cpu.

Here is the example:

let (send, recv) = multiqueue::broadcast_queue(10);
let result = recv.recv(); // <-- while we are here, cpu is 100% hot

Is there a way not to use 100% cpu for reading/waiting? Tried multiqueue::broadcast_fut_queue() - got the same, but I think may be I don't understand some basics. I'm not very experienced in rust.

I'm not talking about async, just want thread not using 100% cpu while it is waiting for new message.

P.S. In some cases I saw cpu goes down to 2-4%, but I am not sure if that was not my code logic mistake.

Env:
MacOS 11.6
rustc 1.55.0 (c8dfcfe04 2021-09-06)

@f0i
Copy link

f0i commented Dec 19, 2021

I experience the same issue on Linux/Docker:
Debian 11.1
rustc 1.56.1 (59eed8a2a 2021-11-01)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants