You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was using hloop_t and hidle_t handle to manage events in my code.
However later I wanted to use multiple WebSocketClient in my code and found out that it accepts EvenLoopPtr to reuse the same event loop, which is what I wanted, so migrated my code to using EventLoopPtr instead of hloop_t.
To run something repeatedly, as like idle handle, I used something like this
eventLoop->postEvent([this](hv::Event* ev){
this->runBusinessLogicInLoop(); //this again fires eventLoop->postEvent to continue looping
});
However I see using this apporach the CPU usage goes too high(shows 12% on my system), however simply using hidle_t does not have any such spike in CPU usage.
Is there similar functionality in EventLoopto go like run something when idle, and how to use it properly ?
I have checked the FAQ and Tutorial
However I am not able find relevant explanation that could have helped in my case.
And have also checked the test cases like EventLoop_test.cpp without success.
Can you please shed some light on how to go with this ?
Thank you in advance for this.
The text was updated successfully, but these errors were encountered:
Ok silly of me.
I completely replaced my Hloop with the EventLoop.
Now using the exsting hloop and passing it into my EventLoop and using it.
So I can keep using the idle handle and use the same event loop in my web sockets.
Hi ithewei,
I was using hloop_t and hidle_t handle to manage events in my code.
However later I wanted to use multiple WebSocketClient in my code and found out that it accepts EvenLoopPtr to reuse the same event loop, which is what I wanted, so migrated my code to using EventLoopPtr instead of hloop_t.
To run something repeatedly, as like idle handle, I used something like this
However I see using this apporach the CPU usage goes too high(shows 12% on my system), however simply using hidle_t does not have any such spike in CPU usage.
Is there similar functionality in
EventLoop
to go like run something when idle, and how to use it properly ?I have checked the FAQ and Tutorial
However I am not able find relevant explanation that could have helped in my case.
And have also checked the test cases like
EventLoop_test.cpp
without success.Can you please shed some light on how to go with this ?
Thank you in advance for this.
The text was updated successfully, but these errors were encountered: