mirror of
https://github.com/danog/ext-uv.git
synced 2024-11-27 04:24:45 +01:00
add uv_idle test case
This commit is contained in:
parent
61cf804725
commit
87334570b1
1
php_uv.c
1
php_uv.c
@ -2384,6 +2384,7 @@ PHP_FUNCTION(uv_idle_start)
|
||||
|
||||
ZEND_FETCH_RESOURCE(uv, php_uv_t *, &idle, -1, PHP_UV_RESOURCE_NAME, uv_resource_handle);
|
||||
Z_ADDREF_P(callback);
|
||||
zend_list_addref(uv->resource_id);
|
||||
|
||||
if (uv->idle_cb) {
|
||||
zval_ptr_dtor(&uv->idle_cb);
|
||||
|
29
tests/300-uv_idle.phpt
Normal file
29
tests/300-uv_idle.phpt
Normal file
@ -0,0 +1,29 @@
|
||||
--TEST--
|
||||
Check for uv_idle_init and uv_idle_start
|
||||
--FILE--
|
||||
<?php
|
||||
$loop = uv_default_loop();
|
||||
$idle = uv_idle_init();
|
||||
|
||||
$i = 0;
|
||||
uv_idle_start($idle, function($stat)
|
||||
use (&$i, $idle, $loop) {
|
||||
|
||||
echo "count: {$i}" . PHP_EOL;
|
||||
$i++;
|
||||
|
||||
if ($i > 3) {
|
||||
uv_idle_stop($idle);
|
||||
uv_unref($idle);
|
||||
}
|
||||
});
|
||||
|
||||
uv_run();
|
||||
|
||||
echo "finished";
|
||||
--EXPECT--
|
||||
count: 0
|
||||
count: 1
|
||||
count: 2
|
||||
count: 3
|
||||
finished
|
Loading…
Reference in New Issue
Block a user