Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21696 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62908 invoked by uid 1010); 27 Jan 2006 01:24:37 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 62892 invoked from network); 27 Jan 2006 01:24:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jan 2006 01:24:37 -0000 X-Host-Fingerprint: 64.233.184.205 wproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.184.205:54834] helo=wproxy.gmail.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id E2/15-03249-55679D34 for ; Thu, 26 Jan 2006 20:24:37 -0500 Received: by wproxy.gmail.com with SMTP id i24so478338wra for ; Thu, 26 Jan 2006 17:24:33 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=mQkO78S8eFcuLwckfF45KRUYbl10hUclnFT9/DkuBtKvoS4mT7Dagu657NG8T3pkQEVImnrClKmBCkg1fiNcy4fkefcyCIwGOgrTliAPBpJKJCRyvBGyWohCexbwsqEtDq8f7+JK3r9WETgHPrw1xp+j2rqHKZyULBWPWQ9dfOo= Received: by 10.54.71.15 with SMTP id t15mr3205641wra; Thu, 26 Jan 2006 17:24:33 -0800 (PST) Received: by 10.54.153.2 with HTTP; Thu, 26 Jan 2006 17:24:33 -0800 (PST) Message-ID: <4e89b4260601261724s553ee5c3o90d95fe5a833694@mail.gmail.com> Date: Fri, 27 Jan 2006 01:24:33 +0000 To: Tom Rogers Cc: internals@lists.php.net In-Reply-To: <1625742483.20060127110715@kwikin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <1625742483.20060127110715@kwikin.com> Subject: Re: [PHP-DEV] usleep() on win32 From: kingwez@gmail.com (Wez Furlong) We've had working usleep on windows since november 2003 in the PHP 5 branch= . Check out win32/time.c --Wez. On 1/27/06, Tom Rogers wrote: > 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() !=3D 1 || zend_get_parameters_ex(1, &num) =3D= =3D 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 > >