Skip to content

Try to avoid 100% cpu usage for reading #32

@maxgorovenko

Description

@maxgorovenko

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions