View Single Post
NerdKnight's Avatar
Posts: 113 | Thanked: 334 times | Joined on Oct 2010 @ Argentina
#5104
Originally Posted by Scorpius View Post
I would actually think your patch consumes even more battery:

1.- Instead of waiting for the I/O system to announce to the application there are bytes pending for reading in the network device, you're polling the network device every second with a timer.

2.- You're polling even when you're not connected. That's why you had to verify if socket is valid (and you used NULL in a C++ program like it were a C program). There's no way to call read() with an invalid socket object since the object had to trigger a signal and to do that it *has* to be valid.

So I'm not sure about this patch.
1- The timer was introduced to process the connection in a separate thread (so the GUI doesn't freeze in case of a bad connection), it was the simplest solution I found at the time, without major rewriting of the code

2- When there is a connection problem or the socket is disconnected, the variable socket is assigned to NULL, so the timer does nothing until a new connection is open.
I can't remember exactly, but in some cases when there was a bad internet connection, the program stuck in a loop, generating the 100% cpu usage, that's why I cheked the socket. The changes in bintreenodereader.cpp where also important.

I been running yappari for months with this patch and the were no more 100% cpu usage, and the battery life is good for me, I haven't notice more battery usage because of this. Anyway I did this patch for me (I couldn't use yappari in the previous state), hope it helps you to find the problem and implement a better solution. Anyway I can help let me know.
 

The Following User Says Thank You to NerdKnight For This Useful Post: