Flying-Toast / simple-websockets

MIT License
18 stars 7 forks source link

High CPU usage? #11

Closed tiye closed 3 years ago

tiye commented 3 years ago

lack of sleep?

image

Flying-Toast commented 3 years ago

Can you post your code? I suspect you are busy-looping on EventHub::next_event(). I recommended using either EventHub::poll_event(), or sleeping in your loop.

I've actually just noticed that the example in the readme uses next_event() instead of poll_event() which would be more correct in this case. I'll update that example, thanks for pointing this out :)

Flying-Toast commented 3 years ago

I've fixed the example in https://github.com/Flying-Toast/simple-websockets/commit/e543bcd6d8c00fd08189411e767133e9b8251a98, could you take a look at the change and see if your code is doing the same thing? Please re-open the issue if you're still having issues.

tiye commented 3 years ago

Looks good now, cheers~

image