Hi Here is a small change to usleep so it will work with win32. It is very useful for tight while loops when using socket functions and reduces cpu load from 100% to 0%-2% (on my win2k box) by just adding usleep(1000); after the while(). (Code snippet was taken from pgsql)
Diff is from php-4.4 cvs RCS file: /repository/php-src/ext/standard/basic_functions.c,v retrieving revision 1.543.2.51.2.6 diff -u -w -b -r1.543.2.51.2.6 basic_functions.c --- basic_functions.c 1 Jan 2006 13:46:57 -0000 1.543.2.51.2.6 +++ basic_functions.c 27 Jan 2006 00:52:10 -0000 @@ -1677,14 +1677,20 @@ Delay for a given number of micro seconds */ PHP_FUNCTION(usleep) { -#if HAVE_USLEEP pval **num; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(num); +#if HAVE_USLEEP usleep(Z_LVAL_PP(num)); +#else +#ifdef PHP_WIN32 + do { + SleepEx((Z_LVAL_PP(num) < 500 ? 1 : (Z_LVAL_PP(num) + 500) / 1000), TRUE); + } while(0); +#endif #endif } /* }}} */ -- Tom -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php