add uv_timer_stop, uv_timer_again, uv_timer_set_repeat, uv_timer_get_repeat api

This commit is contained in:
Shuhei Tanuma 2012-05-31 07:11:52 +09:00
parent b6b3bfdd75
commit 3614801006
2 changed files with 95 additions and 4 deletions

View File

@ -39,10 +39,6 @@
* UV_EXTERN int uv_async_init(uv_loop_t*, uv_async_t* async,uv_async_cb async_cb);
* UV_EXTERN int uv_async_send(uv_async_t* async);
* UV_EXTERN int uv_timer_again(uv_timer_t* timer);
* UV_EXTERN void uv_timer_set_repeat(uv_timer_t* timer, int64_t repeat);
* UV_EXTERN int64_t uv_timer_get_repeat(uv_timer_t* timer);
* UV_EXTERN int uv_ares_init_options(uv_loop_t*,ares_channel *channelptr, struct ares_options *options, int optmask);
* UV_EXTERN void uv_ares_destroy(uv_loop_t*, ares_channel channel);

View File

@ -664,6 +664,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_idle_stop, 0, 0, 1)
ZEND_ARG_INFO(0, idle)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_again, 0, 0, 1)
ZEND_ARG_INFO(0, idle)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_timer_start, 0, 0, 4)
ZEND_ARG_INFO(0, timer)
ZEND_ARG_INFO(0, timeout)
@ -671,6 +675,23 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_timer_start, 0, 0, 4)
ZEND_ARG_INFO(0, callback)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_timer_stop, 0, 0, 1)
ZEND_ARG_INFO(0, timer)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_timer_again, 0, 0, 1)
ZEND_ARG_INFO(0, timer)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_timer_set_repeat, 0, 0, 2)
ZEND_ARG_INFO(0, timer)
ZEND_ARG_INFO(0, timeout)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_timer_get_repeat, 0, 0, 2)
ZEND_ARG_INFO(0, timer)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_idle_start, 0, 0, 2)
ZEND_ARG_INFO(0, timer)
ZEND_ARG_INFO(0, callback)
@ -1255,6 +1276,76 @@ PHP_FUNCTION(uv_timer_start)
}
/* }}} */
/* {{{ */
PHP_FUNCTION(uv_timer_stop)
{
zval *timer;
php_uv_t *uv;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r",&timer) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(uv, php_uv_t *, &timer, -1, PHP_UV_RESOURCE_NAME, uv_resource_handle);
uv_timer_stop((uv_timer_t*)&uv->uv.timer);
}
/* }}} */
/* {{{ */
PHP_FUNCTION(uv_timer_again)
{
zval *timer;
php_uv_t *uv;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r",&timer) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(uv, php_uv_t *, &timer, -1, PHP_UV_RESOURCE_NAME, uv_resource_handle);
uv_timer_again((uv_timer_t*)&uv->uv.timer);
}
/* }}} */
/* {{{ */
PHP_FUNCTION(uv_timer_set_repeat)
{
zval *timer;
php_uv_t *uv;
long repeat;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"rl",&timer,&repeat) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(uv, php_uv_t *, &timer, -1, PHP_UV_RESOURCE_NAME, uv_resource_handle);
uv_timer_set_repeat((uv_timer_t*)&uv->uv.timer,repeat);
}
/* }}} */
/* {{{ */
PHP_FUNCTION(uv_timer_get_repeat)
{
zval *timer;
php_uv_t *uv;
int64_t repeat;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r",&timer) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(uv, php_uv_t *, &timer, -1, PHP_UV_RESOURCE_NAME, uv_resource_handle);
repeat = uv_timer_get_repeat((uv_timer_t*)&uv->uv.timer);
}
/* }}} */
/* {{{ */
PHP_FUNCTION(uv_idle_start)
{
@ -1676,6 +1767,10 @@ static zend_function_entry uv_functions[] = {
/* timer */
PHP_FE(uv_timer_init, arginfo_uv_timer_init)
PHP_FE(uv_timer_start, arginfo_uv_timer_start)
PHP_FE(uv_timer_stop, arginfo_uv_timer_stop)
PHP_FE(uv_timer_again, arginfo_uv_timer_again)
PHP_FE(uv_timer_set_repeat, arginfo_uv_timer_set_repeat)
PHP_FE(uv_timer_get_repeat, arginfo_uv_timer_get_repeat)
/* tcp */
PHP_FE(uv_tcp_init, arginfo_uv_tcp_init)
PHP_FE(uv_tcp_nodelay, arginfo_uv_tcp_nodelay)