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
Hi Andrey,
I didn't get why do you need this extension and how it's going to be used.
Thanks. Dmitry.
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/0zhVNxaYCurrently 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
Hi Dmitry,
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 <php@hristov.com
mailto:php@hristov.com> 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
This is really interesting, but I think use of "ticks" for asynchronous
functions is bad approach.
A month or two ago I published a PoC for safe interrupt handling.
https://github.com/php/php-src/compare/master...dstogov:interrupt
Actually it's already partially committed to support timeout handling on
Windows.
This idea may be extended to implement cooperative-multitasking,
asynchronous callbacks, signal handlers, etc...
I didn't continue work on it yet, because it's too later for PHP-7.0 and I
have a lot of other PHP-7 related work.
If you like to implement MYSQLI_ASYNC
PoC now - just include your ticks
extension there.
If we accept it, we will accept all together.
Thanks. Dmitry.
Hi Dmitry,
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 tomysqli_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,
AndreyThanks. Dmitry.
On Tue, Apr 7, 2015 at 4:43 PM, Andrey Hristov <php@hristov.com
mailto:php@hristov.com> 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