Remove gratuitous sleeps before function exits

Add sleep in tight wait loop to reduce CPU loading.
Hamlib-3.0
Bill Somerville 2014-12-10 01:34:35 +00:00
rodzic 82b8649030
commit aa3fd7ba28
1 zmienionych plików z 6 dodań i 5 usunięć

Wyświetl plik

@ -1397,9 +1397,10 @@ int win32_serial_read( int fd, void *vb, int size )
if (stat.cbInQue < index->ttyset->c_cc[VMIN]) if (stat.cbInQue < index->ttyset->c_cc[VMIN])
{ {
/* /*
usleep(1000);
usleep(50); usleep(50);
*/ */
usleep(100); /* don't hog the CPU while waiting */
/* we should use -1 instead of 0 for disabled timeout */ /* we should use -1 instead of 0 for disabled timeout */
now = GetTickCount(); now = GetTickCount();
if (index->ttyset->c_cc[VTIME] && if (index->ttyset->c_cc[VTIME] &&
@ -3258,7 +3259,7 @@ int win32_serial_select( int n, fd_set *readfds, fd_set *writefds,
this does happen. loops ~twice on a 350 Mzh with this does happen. loops ~twice on a 350 Mzh with
usleep(1000000) usleep(1000000)
*/ */
usleep(10000); /* usleep(10000); */
LEAVE( "serial_uselect" ); LEAVE( "serial_uselect" );
return(0); return(0);
} }
@ -3334,7 +3335,7 @@ int win32_serial_select( int n, fd_set *readfds, fd_set *writefds,
} }
end: end:
/* You may want to chop this out for lower latency */ /* You may want to chop this out for lower latency */
usleep(1000); /* usleep(1000); */
LEAVE( "serial_select" ); LEAVE( "serial_select" );
return( 1 ); return( 1 );
timeout: timeout:
@ -3361,7 +3362,7 @@ int win32_serial_select( int n, fd_set *readfds, fd_set *writefds,
ENTER( "serial_select" ); ENTER( "serial_select" );
if ( fd <= 0 ) if ( fd <= 0 )
{ {
usleep(1000); /* usleep(1000); */
return 1; return 1;
} }
index = find_port( fd ); index = find_port( fd );
@ -3376,7 +3377,7 @@ int win32_serial_select( int n, fd_set *readfds, fd_set *writefds,
} }
while(!index->event_flag ) while(!index->event_flag )
{ {
usleep(1000); /* usleep(1000); */
return -1; return -1;
} }