Fix CPU usage issues.

This commit is contained in:
Thulinma 2012-09-07 17:31:10 +02:00
parent 46e4823daa
commit 414cec2797
3 changed files with 6 additions and 1 deletions

View file

@ -201,6 +201,8 @@ namespace Connector_HTTP{
fprintf(stderr, "Could not parse the following:\n%s\n", conn.Received().c_str()); fprintf(stderr, "Could not parse the following:\n%s\n", conn.Received().c_str());
#endif #endif
} }
}else{
usleep(10000);//sleep 10ms
} }
if (ready4data){ if (ready4data){
if (!inited){ if (!inited){

View file

@ -58,6 +58,8 @@ namespace Connector_HTTP{
fprintf(stderr, "Could not parse the following:\n%s\n", conn.Received().c_str()); fprintf(stderr, "Could not parse the following:\n%s\n", conn.Received().c_str());
#endif #endif
} }
}else{
usleep(10000);//sleep 10ms
} }
if (ready4data){ if (ready4data){
if (!inited){ if (!inited){

View file

@ -76,10 +76,11 @@ int Connector_RTMP::Connector_RTMP(Socket::Connection conn){
bool firstrun = true; bool firstrun = true;
while (Socket.connected()){ while (Socket.connected()){
usleep(10000);//sleep 10ms to prevent high CPU usage
if (Socket.spool() || firstrun){ if (Socket.spool() || firstrun){
firstrun = false; firstrun = false;
parseChunk(Socket.Received()); parseChunk(Socket.Received());
}else{
usleep(10000);//sleep 10ms to prevent high CPU usage
} }
if (ready4data){ if (ready4data){
if (!inited){ if (!inited){