Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85741 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37760 invoked from network); 7 Apr 2015 14:56:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Apr 2015 14:56:50 -0000 Authentication-Results: pb1.pair.com header.from=php@hristov.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@hristov.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain hristov.com from 91.196.125.214 cause and error) X-PHP-List-Original-Sender: php@hristov.com X-Host-Fingerprint: 91.196.125.214 more.superhosting.bg Linux 2.6 Received: from [91.196.125.214] ([91.196.125.214:33520] helo=more.superhosting.bg) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BD/90-33115-D20F3255 for ; Tue, 07 Apr 2015 10:56:48 -0400 Received: from x5f717eb2.dyn.telefonica.de ([95.113.126.178]:57894 helo=[192.168.1.128]) by more.superhosting.bg with esmtpsa (TLSv1:DHE-RSA-AES128-SHA:128) (Exim 4.84) (envelope-from ) id 1YfUvi-003mfq-Fl; Tue, 07 Apr 2015 17:56:42 +0300 Message-ID: <5523F025.5070407@hristov.com> Date: Tue, 07 Apr 2015 16:56:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Dmitry Stogov CC: PHP internals References: <5523DF0E.6000500@hristov.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - more.superhosting.bg X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - hristov.com X-Get-Message-Sender-Via: more.superhosting.bg: authenticated_id: php@hristov.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PATCH] Tick functions (on C level) with state From: php@hristov.com (Andrey Hristov) Hi Dmitry, On 7.04.2015 16:33, Dmitry Stogov wrote: > Hi Andrey, > > I didn't get why do you need this extension and how it's going to be used. I would like to implement (I have a PoC for this too), asynchronous query handlers in mysqli@mysqlnd. Currently it is possible to have some asynchronisity like $c = mysqli_query("....", MYSQLI_ASYNC); // do some work // poll with mysqli_poll // synchronise with mysqli_reap_async_query // fetch data I would like to skip the //poll and in some cases the //synchronise part and have $c = mysqli_query("....", MYSQLI_ASYNC, function () use ($c) { $res = mysqli_reap_async_query($c); // do something with the result } ); The closure can also set some global flag, and somewhere in the "main" thread it one can synchronize on it. It can also use [class, method] callback syntax. For example one can subclass class mysqli, add some status variables for state, and a method to pass to mysqli_query()/ mysqli::query(). mysqlnd registers a small tick function, that does select, and if there is data to be read the closure is called. Another closure for handling an error should be added too (but I don't have it my PoC). Hope this helps to enlighten my intentions. Best, Andrey > Thanks. Dmitry. > > On Tue, Apr 7, 2015 at 4:43 PM, Andrey Hristov > wrote: > > Hi, > I would like to hear comments about a small change to the low-level > tick functionality (main/php_ticks.c) to add state to when calling a > C tick function > The patch is alive at : http://pastebin.com/0zhVNxaY > > Currently a C tick function gets as a parameter just the number of > ticks, and can't preserve state between calls. On PHP level one can > use closures to mitigate this, but in the C world we don't have this > luxury. > > Any comments are very welcome. If possible to get in PHP7. > > > Cheers, > Andrey > >