for now, add rwlock functions

This commit is contained in:
Shuhei Tanuma 2012-06-17 21:11:16 +09:00
parent efbdc8bef2
commit 4d57292d8d
2 changed files with 34 additions and 7 deletions

View File

@ -88,13 +88,6 @@
* UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle);
* UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle);
* UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock);
* UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock);
* UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock);
* UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock);
* UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock);
* UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock);
* UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void));
* UV_EXTERN int uv_thread_create(uv_thread_t *tid,void (*entry)(void *arg), void *arg);
* UV_EXTERN int uv_thread_join(uv_thread_t *tid);

View File

@ -2779,6 +2779,38 @@ PHP_FUNCTION(uv_rwlock_wrlock)
}
/* }}} */
/* {{{ */
PHP_FUNCTION(uv_rwlock_trywrlock)
{
uv_rwlock_t *lock;
zval *handle;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"z", &handle) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(lock, uv_rwlock_t *, &handle, -1, PHP_UV_RWLOCK_RESOURCE_NAME, uv_rwlock_handle);
RETURN_LONG(uv_rwlock_trywrlock(lock));
}
/* }}} */
/* {{{ */
PHP_FUNCTION(uv_rwlock_wrunlock)
{
uv_rwlock_t *lock;
zval *handle;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"z", &handle) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(lock, uv_rwlock_t *, &handle, -1, PHP_UV_RWLOCK_RESOURCE_NAME, uv_rwlock_handle);
uv_rwlock_wrunlock(lock);
}
/* }}} */
static zend_function_entry uv_functions[] = {
/* general */
@ -2851,6 +2883,8 @@ static zend_function_entry uv_functions[] = {
PHP_FE(uv_rwlock_tryrdlock, NULL)
PHP_FE(uv_rwlock_rdunlock, NULL)
PHP_FE(uv_rwlock_wrlock, NULL)
PHP_FE(uv_rwlock_trywrlock, NULL)
PHP_FE(uv_rwlock_wrunlock, NULL)
/* info */
PHP_FE(uv_loadavg, NULL)
PHP_FE(uv_uptime, NULL)