View Single Post
Scorpius's Avatar
Posts: 1,396 | Thanked: 2,796 times | Joined on Sep 2010 @ Caracas, Venezuela
#5095
Originally Posted by NerdKnight View Post
mmm, I made this a while ago, I put some network read function in a separated thread (so the gui doesn't freeze when there is some connection problem) and validated the socket connection if is valid before using it.
Here the patch with the battery fix and here the whole patch.
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.
__________________
Support Yappari (a Whatsapp client for the N900 only) - Donate