Source

pecl-ev / check.c

Diff from to
 #include "watcher.h"
 
 /* {{{ php_ev_check_object_ctor */
-void php_ev_check_object_ctor(INTERNAL_FUNCTION_PARAMETERS, zval *loop)
+void php_ev_check_object_ctor(INTERNAL_FUNCTION_PARAMETERS, zval *loop, zend_bool ctor, zend_bool start)
 {
 	zval                  *self;
 	php_ev_object         *o_self;
 	php_ev_object         *o_loop;
-	ev_check              *check_watcher;
+	ev_check              *w;
 
-	zval                  *data          = NULL;
-	zend_fcall_info        fci           = empty_fcall_info;
-	zend_fcall_info_cache  fcc           = empty_fcall_info_cache;
-	long                   priority      = 0;
+	zval                  *data     = NULL;
+	zend_fcall_info        fci      = empty_fcall_info;
+	zend_fcall_info_cache  fcc      = empty_fcall_info_cache;
+	long                   priority = 0;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f|z!l",
 				&fci, &fcc, &data, &priority) == FAILURE) {
 		self = getThis();
 	}
 
-	o_self        = (php_ev_object *) zend_object_store_get_object(self TSRMLS_CC);
-	o_loop        = (php_ev_object *) zend_object_store_get_object(loop TSRMLS_CC);
-	check_watcher = (ev_check *) php_ev_new_watcher(sizeof(ev_check), self,
+	o_self = (php_ev_object *) zend_object_store_get_object(self TSRMLS_CC);
+	o_loop = (php_ev_object *) zend_object_store_get_object(loop TSRMLS_CC);
+	w      = (ev_check *) php_ev_new_watcher(sizeof(ev_check), self,
 			PHP_EV_LOOP_OBJECT_FETCH_FROM_OBJECT(o_loop),
 			&fci, &fcc, data, priority TSRMLS_CC);
 
-	check_watcher->type = EV_CHECK;
+	w->type = EV_CHECK;
 
-	o_self->ptr = (void *) check_watcher;
+	o_self->ptr = (void *) w;
+
+	if (start) {
+		PHP_EV_WATCHER_START(ev_check, w);
+	}
 }
 /* }}} */
 
 /* {{{ proto EvCheck::__construct(callable callback[, mixed data = NULL[, int priority = 0]]) */
 PHP_METHOD(EvCheck, __construct)
 {
-	php_ev_check_object_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL);
+	PHP_EV_WATCHER_CTOR(check, NULL);
+}
+/* }}} */
+
+/* {{{ proto EvCheck::createStopped(callable callback[, mixed data = NULL[, int priority = 0]]) */
+PHP_METHOD(EvCheck, createStopped)
+{
+	PHP_EV_WATCHER_FACTORY_NS(check, NULL);
 }
 /* }}} */