diff --git a/php_uv.c b/php_uv.c index c6f8ca9..0efa9a2 100644 --- a/php_uv.c +++ b/php_uv.c @@ -2688,6 +2688,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_run, 0, 0, 1) ZEND_ARG_INFO(0, loop) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_stop, 0, 0, 1) + ZEND_ARG_INFO(0, loop) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_loop_delete, 0, 0, 1) ZEND_ARG_INFO(0, loop) ZEND_END_ARG_INFO() @@ -3483,6 +3487,22 @@ PHP_FUNCTION(uv_run) } /* }}} */ +/* {{{ proto void uv_stop([resource $uv_loop]) +*/ +PHP_FUNCTION(uv_stop) +{ + zval *zloop = NULL; + uv_loop_t *loop; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, + "|z",&zloop) == FAILURE) { + return; + } + PHP_UV_FETCH_UV_DEFAULT_LOOP(loop, zloop); + uv_stop(loop); +} +/* }}} */ + /* {{{ proto long uv_run_once([resource $uv_loop]) */ PHP_FUNCTION(uv_run_once) @@ -6439,6 +6459,7 @@ static zend_function_entry uv_functions[] = { PHP_FE(uv_unref, arginfo_uv_unref) PHP_FE(uv_loop_new, NULL) PHP_FE(uv_default_loop, NULL) + PHP_FE(uv_stop, arginfo_uv_stop) PHP_FE(uv_run, arginfo_uv_run) PHP_FE(uv_run_once, arginfo_uv_run_once) PHP_FE(uv_ip4_addr, arginfo_uv_ip4_addr) diff --git a/tests/100-uv_stop.phpt b/tests/100-uv_stop.phpt new file mode 100755 index 0000000..4dc0e6f --- /dev/null +++ b/tests/100-uv_stop.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test uv_stop ends loop execution +--FILE-- + 3) { + uv_stop($loop); + } +}); + +uv_run(); + +echo "finished" . PHP_EOL; +--EXPECT-- +count: 0 +count: 1 +count: 2 +count: 3 +finished \ No newline at end of file