Ruslan Osmanov avatar Ruslan Osmanov committed ba91e77

Change: moved ev_* functions to Ev singleton(due to some issues with reflection)
Change: renamed EvLoop::break to EvLoop::stop, and ev_break to Ev::stop
Fix: release version

Comments (0)

Files changed (14)

 	// until we manually stop it
 	$w2 = new EvTimer(2, 1, function ($w) {
 		echo "is called every second, is launched after 2 seconds\n";
-		echo "iteration = ", ev_iteration(), PHP_EOL;
+		echo "iteration = ", Ev::iteration(), PHP_EOL;
 
 		// Stop the watcher after 5 iterations
-		ev_iteration() == 5 and $w->stop();
+		Ev::iteration() == 5 and $w->stop();
 		// Stop the watcher if further calls cause more than 10 iterations
-		ev_iteration() >= 10 and $w->stop();
+		Ev::iteration() >= 10 and $w->stop();
 	});
 
 	// Create stopped timer. It will be inactive until we start it ourselves
 		echo "Callback of a timer created as stopped\n";
 
 		// Stop the watcher after 2 iterations
-		ev_iteration() >= 2 and $w->stop();
+		Ev::iteration() >= 2 and $w->stop();
 	});
 
-	// Loop until ev_break() is called or all of watchers stop
-	ev_run();
+	// Loop until Ev::stop() is called or all of watchers stop
+	Ev::run();
 
 	// Start and look if it works
 	$w_stopped->start();
 	echo "Run single iteration\n";
-	ev_run(EVRUN_ONCE);
+	Ev::run(EVRUN_ONCE);
 
 	echo "Restart the second watcher and try to handle the same events, but don't block\n";
 	$w2->again();
-	ev_run(EVRUN_NOWAIT);
+	Ev::run(EVRUN_NOWAIT);
 
 	$w = new EvTimer(10, 0, function() {});
 	echo "Running a blocking loop\n";
-	ev_run();
+	Ev::run();
 	echo "END\n";
 	?>
 
 	$w = new EvPeriodic(0., 10.5, NULL, function ($w, $revents) {
 		echo time(), PHP_EOL;
 	});
-	ev_run();
+	Ev::run();
 	?>
 
 *Example 2*
 	$w = new EvPeriodic(0., 0., "reschedule_cb", function ($w, $revents) {
 		echo time(), PHP_EOL;
 	});
-	ev_run();
+	Ev::run();
 	?>
 
 *Example 3*
 
 	<?php
 	// Tick every 10.5 seconds starting at now
-	$w = new EvPeriodic(fmod(ev_now(), 10.5), 10.5, NULL, function ($w, $revents) {
+	$w = new EvPeriodic(fmod(Ev::now(), 10.5), 10.5, NULL, function ($w, $revents) {
 		echo time(), PHP_EOL;
 	});
-	ev_run();
+	Ev::run();
 	?>
 
 I/O EVENTS
 	$w = new EvIo(STDIN, EV_READ, function ($watcher, $revents) {
 		echo "STDIN is readable\n";
 	});
-	ev_run(EVRUN_ONCE);
+	Ev::run(EVRUN_ONCE);
 	?>
 
 *Example 2*
 	// Abort on timeout
 	$timeout_watcher = new EvTimer(10.0, 0., function () use ($socket) {
 		socket_close($socket);
-		ev_break(EVBREAK_ALL);
+		Ev::stop(EVBREAK_ALL);
 	});
 
 	// Make HEAD request when the socket is writable
 			socket_close($socket);
 		});
 
-		ev_run();
+		Ev::run();
 	});
 
 	$result = socket_connect($socket, $address, $service_port);
 
-	ev_run();
+	Ev::run();
 	?>
 
 Sample output:
 
 	<?php
 	/*
- 	 * Try to get an embeddable event loop and embed it into the default event loop. 
+ 	 * Try to get an embeddable event loop and embed it into the default event loop.
  	 * If it is impossible, use the default
- 	 * loop. The default loop is stored in $loop_hi, while the embeddable loop is 
- 	 * stored in $loop_lo(which is $loop_hi in the case no embeddable loop can be 
+ 	 * loop. The default loop is stored in `$loop_hi`, while the embeddable loop is
+ 	 * stored in `$loop_lo`(which is `$loop_hi` in the case no embeddable loop can be
  	 * used).
- 	 * 
+ 	 *
  	 * Sample translated to PHP
- 	 * http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#Examples_CONTENT-9
+ 	 * <http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#Examples_CONTENT-9>
  	 */
 	$loop_hi = EvLoop::defaultLoop();
 	$loop_lo = NULL;
 	* See if there is a chance of getting one that works
 	* (flags' value of 0 means autodetection)
 	*/
-	$loop_lo = ev_embeddable_backends() & ev_recommended_backends()
-    	? new EvLoop(ev_embeddable_backends() & ev_recommended_backends())
+	$loop_lo = Ev::embeddableBackends() & Ev::recommendedBackends()
+    	? new EvLoop(Ev::embeddableBackends() & Ev::recommendedBackends())
     	: 0;
 
 	if ($loop_lo) {
 
 	<?php
 	/*
- 	 * Check if kqueue is available but not recommended and create a kqueue backend 
- 	 * for use with sockets (which usually work with any kqueue implementation). 
- 	 * Store the kqueue/socket-only event loop in loop_socket. (One might optionally 
- 	 * use EVFLAG_NOENV, too)
+ 	 * Check if kqueue is available but not recommended and create a kqueue backend
+ 	 * for use with sockets (which usually work with any kqueue implementation).
+ 	 * Store the kqueue/socket-only event loop in `$socket_loop`. (One might optionally
+ 	 * use `EVFLAG_NOENV`, too)
  	 *
  	 * Example borrowed from
- 	 * http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#Examples_CONTENT-9
+ 	 * <http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#Examples_CONTENT-9>
  	 */
 	$loop        = EvLoop::defaultLoop();
 	$socket_loop = NULL;
 	$embed       = NULL;
 
-	if (ev_supported_backends() & ~ev_recommended_backends() & EVBACKEND_KQUEUE) {
+	if (Ev::supportedBackends() & ~Ev::recommendedBackends() & EVBACKEND_KQUEUE) {
 		if (($socket_loop = new EvLoop(EVBACKEND_KQUEUE))) {
 			$embed = new EvEmbed($loop);
 		}
 	}
 
 	if (!$socket_loop) {
-		$socket_loop = $loop; 
+		$socket_loop = $loop;
 	}
 
 	// Now use $socket_loop for all sockets, and $loop for anything else
 		echo "SIGTERM received\n";
 		$watcher->stop();
 	});
-	ev_run();
+	Ev::run();
 	?>
 
 STAT - FILE STATUS CHANGES
 		}
 	});
 
-	ev_run();
+	Ev::run();
 	?>
 
 *Example 2*
 
 	$timer->data = $stat;
 
-	ev_run();
+	Ev::run();
 	?>
 
 PROCESS STATUS CHANGES
 			printf("Process %d exited with status %d\n", $w->rpid, $w->rstatus);
 		});
 
-		ev_run();
+		Ev::run();
 
 		// Protect against Zombies
 		pcntl_wait($status);
 ZEND_DECLARE_MODULE_GLOBALS(ev)
 static PHP_GINIT_FUNCTION(ev);
 
+zend_class_entry *ev_class_entry_ptr;
 zend_class_entry *ev_loop_class_entry_ptr;
 zend_class_entry *ev_watcher_class_entry_ptr;
 zend_class_entry *ev_io_class_entry_ptr;
 	STANDARD_MODULE_HEADER,
 #endif
     "ev",
-    ev_functions,
+    NULL, /* functions */
     PHP_MINIT(ev),
     PHP_MSHUTDOWN(ev),
     NULL,                         /* PHP_RINIT(ev)     */
 {
 	zend_class_entry *ce;
 
+	/* {{{ Ev */
+	PHP_EV_REGISTER_CLASS_ENTRY("Ev", ev_class_entry_ptr, ev_class_entry_functions);
+	ce = ev_class_entry_ptr;
+	ce->ce_flags |= ZEND_ACC_FINAL_CLASS;
+	/* }}} */
+
 	/* {{{ EvLoop */
 	PHP_EV_REGISTER_CLASS_ENTRY("EvLoop", ev_loop_class_entry_ptr, ev_loop_class_entry_functions);
 	ce = ev_loop_class_entry_ptr;
 #include "loop.c" 
 
 
-/* {{{ Global functions */
+/* {{{ Ev methods */
 
-#define PHP_EV_FUNC_INT_VOID(name)                                                \
-    PHP_FUNCTION(ev_ ## name)                                                     \
+#define PHP_EV_METHOD_INT_VOID(name, method)                                      \
+    PHP_METHOD(Ev, method)                                                        \
     {                                                                             \
         if (zend_parse_parameters_none() == FAILURE) {                            \
             return;                                                               \
         RETURN_LONG((long) ev_ ## name());                                        \
     }
 
-#define PHP_EV_LOOP_FUNC_INT_VOID(name)                                           \
-    PHP_FUNCTION(ev_ ## name)                                                     \
+#define PHP_EV_METHOD_DEFAULT_LOOP_INT_VOID(name, method)                         \
+    PHP_METHOD(Ev, method)                                                        \
     {                                                                             \
         zval          *zloop;                                                     \
         php_ev_object *ev_obj;                                                    \
         RETURN_LONG(ev_ ## name(PHP_EV_LOOP_FETCH_FROM_OBJECT(ev_obj)));          \
     }
 
-#define PHP_EV_LOOP_FUNC_VOID_VOID(name)                                          \
-    PHP_FUNCTION(ev_ ## name)                                                     \
+#define PHP_EV_METHOD_VOID_VOID(name, method)                                     \
+    PHP_METHOD(Ev, method)                                                        \
     {                                                                             \
         zval          *zloop;                                                     \
         php_ev_object *ev_obj;                                                    \
                                                                                   \
         ev_ ## name(PHP_EV_LOOP_FETCH_FROM_OBJECT(ev_obj));                       \
     }
-/* }}} */
 
-PHP_EV_FUNC_INT_VOID(supported_backends)
-PHP_EV_FUNC_INT_VOID(recommended_backends)
-PHP_EV_FUNC_INT_VOID(embeddable_backends)
+PHP_EV_METHOD_INT_VOID(supported_backends,   supportedBackends)
+PHP_EV_METHOD_INT_VOID(recommended_backends, recommendedBackends)
+PHP_EV_METHOD_INT_VOID(embeddable_backends,  embeddableBackends)
 
-/* {{{ proto void ev_feed_signal(int signum) */
-PHP_FUNCTION(ev_feed_signal)
+/* {{{ proto void Ev::feedSignal(int signum) */
+PHP_METHOD(Ev, feedSignal)
 {
 	long signum;
 
 }
 /* }}} */
 
-/* {{{ proto void ev_sleep(double seconds) */
-PHP_FUNCTION(ev_sleep)
+/* {{{ proto void Ev::sleep(double seconds) */
+PHP_METHOD(Ev, sleep)
 {
 	double seconds;
 
 }
 /* }}} */
 
-/* {{{ proto double ev_time(void) */
-PHP_FUNCTION(ev_time)
+/* {{{ proto double Ev::time(void) */
+PHP_METHOD(Ev, time)
 {
     if (zend_parse_parameters_none() == FAILURE) {
         return;
 }
 /* }}} */
 
-/* {{{ proto void ev_run([int flags = 0]) */
-PHP_FUNCTION(ev_run)
+/* {{{ proto void Ev::run([int flags = 0]) */
+PHP_METHOD(Ev, run)
 {
 	long           flags  = 0;
 	zval          *zloop;
 }
 /* }}} */
 
-/* {{{ proto double ev_now(void) */
-PHP_FUNCTION(ev_now)
+/* {{{ proto double Ev::now(void) */
+PHP_METHOD(Ev, now)
 {
 	zval          *zloop;
 	php_ev_object *ev_obj;
 }
 /* }}} */
 
-/* {{{ proto void ev_break([int how = 0]) */
-PHP_FUNCTION(ev_break)
+/* {{{ proto void Ev::stop([int how = 0]) */
+PHP_METHOD(Ev, stop)
 {
 	long  how   = EVBREAK_ONE;
 	zval *zloop;
 }
 /* }}} */
 
-/* {{{ proto int ev_iteration(void) */
-PHP_EV_LOOP_FUNC_INT_VOID(iteration)
-/* }}} */
-
-/* {{{ proto int ev_depth(void) */
-PHP_EV_LOOP_FUNC_INT_VOID(depth)
-/* }}} */
-
-/* {{{ proto void ev_verify(void) */
-PHP_FUNCTION(ev_verify)
+/* {{{ proto void Ev::verify(void) */
+PHP_METHOD(Ev, verify)
 {
 	zval *zloop;
 	php_ev_object *ev_obj;
 }
 /* }}} */
 
-/* {{{ proto int ev_backend(void) */
-PHP_EV_LOOP_FUNC_INT_VOID(backend)
-/* }}} */
-
-/* {{{ proto void ev_now_update(void) */
-PHP_EV_LOOP_FUNC_VOID_VOID(now_update)
-/* }}} */
+PHP_EV_METHOD_DEFAULT_LOOP_INT_VOID(iteration, iteration)
+PHP_EV_METHOD_DEFAULT_LOOP_INT_VOID(depth,     depth)
+PHP_EV_METHOD_DEFAULT_LOOP_INT_VOID(backend,   backend)
 
-/* {{{ proto void ev_suspend(void) */
-PHP_EV_LOOP_FUNC_VOID_VOID(suspend)
+PHP_EV_METHOD_VOID_VOID(now_update, nowUpdate)
+PHP_EV_METHOD_VOID_VOID(suspend,    suspend)
+PHP_EV_METHOD_VOID_VOID(resume,     resume)
 /* }}} */
 
-/* {{{ proto void ev_resume(void) */
-PHP_EV_LOOP_FUNC_VOID_VOID(resume)
-/* }}} */
-
-
-/* }}} */
 
 #endif /* HAVE_EV */
 
 	ZEND_ARG_INFO(0, flags)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ev_break, 0, 0, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ev_stop, 0, 0, 0)
 	ZEND_ARG_INFO(0, how)
 ZEND_END_ARG_INFO();
 
 
 /* ARGINFO }}} */
 
-PHP_METHOD(EvLoop, supported_backends);
-PHP_METHOD(EvLoop, recommended_backends);
-PHP_METHOD(EvLoop, embeddable_backends);
-PHP_METHOD(EvLoop, feed_signal);
-
-/* {{{ ev_functions[] */
-const zend_function_entry ev_functions[] = {
-	PHP_FE(ev_supported_backends,   arginfo_ev__void)
-	PHP_FE(ev_recommended_backends, arginfo_ev__void)
-	PHP_FE(ev_embeddable_backends,  arginfo_ev__void)
-	PHP_FE(ev_sleep,                arginfo_ev_sleep)
-	PHP_FE(ev_time,                 arginfo_ev__void)
-	PHP_FE(ev_feed_signal,          arginfo_ev_feed_signal)
-	PHP_FE(ev_run,                  arginfo_ev_run)
-	PHP_FE(ev_now,                  arginfo_ev__void)
-	PHP_FE(ev_break,                arginfo_ev_break)
-	PHP_FE(ev_iteration,            arginfo_ev__void)
-	PHP_FE(ev_depth,                arginfo_ev__void)
-	PHP_FE(ev_verify,               arginfo_ev__void)
-	PHP_FE(ev_backend,              arginfo_ev__void)
-
-	{NULL, NULL, NULL}
+/* {{{ ev_class_entry_functions */
+const zend_function_entry ev_class_entry_functions[] = {
+	PHP_ME(Ev, supportedBackends,   arginfo_ev__void,       ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, recommendedBackends, arginfo_ev__void,       ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, embeddableBackends,  arginfo_ev__void,       ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, sleep,               arginfo_ev_sleep,       ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, time,                arginfo_ev__void,       ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, feedSignal,          arginfo_ev_feed_signal, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, run,                 arginfo_ev_run,         ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, now,                 arginfo_ev__void,       ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, stop,                arginfo_ev_stop,        ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, iteration,           arginfo_ev__void,       ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, depth,               arginfo_ev__void,       ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, verify,              arginfo_ev__void,       ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, backend,             arginfo_ev__void,       ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, nowUpdate,           arginfo_ev__void,       ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, suspend,             arginfo_ev__void,       ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+	PHP_ME(Ev, resume,              arginfo_ev__void,       ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
+
+	{ NULL, NULL, NULL }
 };
 /* }}} */
 
 /* {{{ ev_loop_class_entry_functions */
 const zend_function_entry ev_loop_class_entry_functions[] = {
-	PHP_ME(EvLoop, __construct,       arginfo_ev_default_loop,      ZEND_ACC_PUBLIC  | ZEND_ACC_CTOR)
-	PHP_ME(EvLoop, defaultLoop,       arginfo_ev_default_loop,      ZEND_ACC_PUBLIC  | ZEND_ACC_STATIC)
-	PHP_ME(EvLoop, loopFork,          arginfo_ev__void,             ZEND_ACC_PUBLIC)
-	PHP_ME(EvLoop, verify,            arginfo_ev__void,             ZEND_ACC_PUBLIC)
-	PHP_ME(EvLoop, invokePending,     arginfo_ev__void,             ZEND_ACC_PUBLIC)
-	PHP_ME(EvLoop, nowUpdate,         arginfo_ev__void,             ZEND_ACC_PUBLIC)
-	PHP_ME(EvLoop, suspend,           arginfo_ev__void,             ZEND_ACC_PUBLIC)
-	PHP_ME(EvLoop, resume,            arginfo_ev__void,             ZEND_ACC_PUBLIC)
-	PHP_ME(EvLoop, backend,           arginfo_ev__void,             ZEND_ACC_PUBLIC)
-	PHP_ME(EvLoop, now,               arginfo_ev__void,             ZEND_ACC_PUBLIC)
-	PHP_ME(EvLoop, run,               arginfo_ev_run,               ZEND_ACC_PUBLIC)
-	PHP_ME(EvLoop, break,             arginfo_ev_break,             ZEND_ACC_PUBLIC)
-	PHP_ME(EvLoop, feedSignalEvent,  arginfo_ev_feed_signal_event, ZEND_ACC_PUBLIC)
-	PHP_ME(EvLoop, io,                arginfo_ev_loop_io,           ZEND_ACC_PUBLIC)
-	PHP_ME(EvLoop, timer,             arginfo_ev_loop_timer,        ZEND_ACC_PUBLIC)
+	PHP_ME(EvLoop, __construct,     arginfo_ev_default_loop,      ZEND_ACC_PUBLIC  | ZEND_ACC_CTOR)
+	PHP_ME(EvLoop, defaultLoop,     arginfo_ev_default_loop,      ZEND_ACC_PUBLIC  | ZEND_ACC_STATIC)
+	PHP_ME(EvLoop, loopFork,        arginfo_ev__void,             ZEND_ACC_PUBLIC)
+	PHP_ME(EvLoop, verify,          arginfo_ev__void,             ZEND_ACC_PUBLIC)
+	PHP_ME(EvLoop, invokePending,   arginfo_ev__void,             ZEND_ACC_PUBLIC)
+	PHP_ME(EvLoop, nowUpdate,       arginfo_ev__void,             ZEND_ACC_PUBLIC)
+	PHP_ME(EvLoop, suspend,         arginfo_ev__void,             ZEND_ACC_PUBLIC)
+	PHP_ME(EvLoop, resume,          arginfo_ev__void,             ZEND_ACC_PUBLIC)
+	PHP_ME(EvLoop, backend,         arginfo_ev__void,             ZEND_ACC_PUBLIC)
+	PHP_ME(EvLoop, now,             arginfo_ev__void,             ZEND_ACC_PUBLIC)
+	PHP_ME(EvLoop, run,             arginfo_ev_run,               ZEND_ACC_PUBLIC)
+	PHP_ME(EvLoop, stop,            arginfo_ev_stop,              ZEND_ACC_PUBLIC)
+	PHP_ME(EvLoop, feedSignalEvent, arginfo_ev_feed_signal_event, ZEND_ACC_PUBLIC)
+	PHP_ME(EvLoop, io,              arginfo_ev_loop_io,           ZEND_ACC_PUBLIC)
+	PHP_ME(EvLoop, timer,           arginfo_ev_loop_timer,        ZEND_ACC_PUBLIC)
 #if EV_PERIODIC_ENABLE
 	PHP_ME(EvLoop, periodic,          arginfo_ev_loop_periodic,     ZEND_ACC_PUBLIC)
 #endif
 
 #include "embed.h"
 
-PHP_FUNCTION(ev_supported_backends);
-PHP_FUNCTION(ev_recommended_backends);
-PHP_FUNCTION(ev_embeddable_backends);
-PHP_FUNCTION(ev_feed_signal);
-PHP_FUNCTION(ev_sleep);
-PHP_FUNCTION(ev_time);
-PHP_FUNCTION(ev_run);
-PHP_FUNCTION(ev_now);
-PHP_FUNCTION(ev_break);
-PHP_FUNCTION(ev_iteration);
-PHP_FUNCTION(ev_depth);
-PHP_FUNCTION(ev_verify);
-PHP_FUNCTION(ev_backend);
-PHP_FUNCTION(ev_now_update);
-PHP_FUNCTION(ev_suspend);
-PHP_FUNCTION(ev_resume);
+/* {{{ Ev */
+PHP_METHOD(Ev, supportedBackends);
+PHP_METHOD(Ev, recommendedBackends);
+PHP_METHOD(Ev, embeddableBackends);
+PHP_METHOD(Ev, feedSignal);
+PHP_METHOD(Ev, sleep);
+PHP_METHOD(Ev, time);
+PHP_METHOD(Ev, run);
+PHP_METHOD(Ev, now);
+PHP_METHOD(Ev, stop);
+PHP_METHOD(Ev, iteration);
+PHP_METHOD(Ev, depth);
+PHP_METHOD(Ev, verify);
+PHP_METHOD(Ev, backend);
+PHP_METHOD(Ev, nowUpdate);
+PHP_METHOD(Ev, suspend);
+PHP_METHOD(Ev, resume);
+/* }}} */
 
 /* {{{ EvLoop */
 PHP_METHOD(EvLoop, __construct);
 PHP_METHOD(EvLoop, backend);
 PHP_METHOD(EvLoop, now);
 PHP_METHOD(EvLoop, run);
-PHP_METHOD(EvLoop, break);
+PHP_METHOD(EvLoop, stop);
 PHP_METHOD(EvLoop, feedSignalEvent);
 PHP_METHOD(EvLoop, io);
 PHP_METHOD(EvLoop, timer);
 }
 /* }}} */
 
-/* {{{ proto void EvLoop::break([int how = 0]) */
-PHP_METHOD(EvLoop, break)
+/* {{{ proto void EvLoop::stop([int how = 0]) */
+PHP_METHOD(EvLoop, stop)
 {
 	PHP_EV_LOOP_FETCH_FROM_THIS;
 
     <email>osmanov@php.net</email>
     <active>yes</active>
   </lead>
-  <date>2012-12-24</date>
+  <date>2012-12-26</date>
   <!--{{{ Current version -->
   <version>
-    <release>0.1.2</release>
-    <api>0.1.0</api>
+    <release>0.2.0</release>
+    <api>0.2.0</api>
   </version>
   <stability>
     <release>beta</release>
   </stability>
   <license uri="http://www.php.net/license">PHP</license>
   <notes>
-  Small fixes
+  Change: moved ev_* functions to Ev singleton(due to some issues with reflection)
+  Change: renamed EvLoop::break to EvLoop::stop, and ev_break to Ev::stop
+  Fix: release version
   </notes>
   <!--}}}-->
   <!--{{{ Contents -->
   </extsrcrelease>
   <!--{{{ changelog-->
   <changelog>
-  <!--{{{ 0.1.2 (beta) -->
+  <!--{{{ 0.2.0 (beta) -->
   <version>
-    <release>0.1.2</release>
-    <api>0.1.0</api>
+    <release>0.2.0</release>
+    <api>0.2.0</api>
   </version>
   <stability>
     <release>beta</release>
   </stability>
   <license uri="http://www.php.net/license">PHP</license>
   <notes>
-  Small fixes
+  Change: moved ev_* functions to Ev singleton(due to some issues with reflection)
+  Change: renamed EvLoop::break to EvLoop::stop, and ev_break to Ev::stop
+  Fix: release version
   </notes>
   <!--}}}-->
     <!--{{{ 0.1.1 (beta) -->
 extern zend_module_entry ev_module_entry;
 #define phpext_ev_ptr &ev_module_entry
 
-#define PHP_EV_VERSION "0.1.2"
+#define PHP_EV_VERSION "0.2.0"
 
 #endif /* PHP_EV_H */
 
 #include "macros.h"
 
 extern const zend_function_entry ev_functions[];
+extern const zend_function_entry ev_class_entry_functions[];
 extern const zend_function_entry ev_loop_class_entry_functions[];
 extern const zend_function_entry ev_watcher_class_entry_functions[];
 extern const zend_function_entry ev_io_class_entry_functions[];

tests/04_timer_variation.phpt

 
 error_reporting(0);
 
-$a = new EvTimer(1.6, 0, function() { echo "not ok 2\n"; ev_break(); });
-$b = new EvTimer(0.3, 0, function() { echo "ok 2\n"; ev_break(); });
+
+$a = new EvTimer(1.6, 0, function() { echo "not ok 2\n"; Ev::stop(); });
+$b = new EvTimer(0.3, 0, function() { echo "ok 2\n"; Ev::stop(); });
 
 echo "ok 1\n";
-ev_run();
+Ev::run();
 echo "ok 3\n";
 
-$b = new EvTimer(0.3, 0, function() { echo "ok 5\n"; ev_break(); });
-$a = new EvTimer(1.6, 0, function() { echo "not ok 5\n"; ev_break(); });
+$b = new EvTimer(0.3, 0, function() { echo "ok 5\n"; Ev::stop(); });
+$a = new EvTimer(1.6, 0, function() { echo "not ok 5\n"; Ev::stop(); });
 
 echo "ok 4\n";
-ev_run();
+Ev::run();
 echo "ok 6\n";
 
-$a = new EvTimer(1.9, 0, function() { echo "not ok 8\n"; ev_break(); });
-$b = new EvTimer(1.6, 0, function() { echo "not ok 8\n"; ev_break(); });
-$c = new EvTimer(0.3, 0, function() { echo "ok 8\n"; ev_break(); });
+$a = new EvTimer(1.9, 0, function() { echo "not ok 8\n"; Ev::stop(); });
+$b = new EvTimer(1.6, 0, function() { echo "not ok 8\n"; Ev::stop(); });
+$c = new EvTimer(0.3, 0, function() { echo "ok 8\n"; Ev::stop(); });
 
 echo "ok 7\n";
-ev_run();
+Ev::run();
 echo "ok 9\n";
 
-$a = new EvTimer(1.6, 0, function() { echo "not ok 11\n"; ev_break(); });
-$b = new EvTimer(0.3, 0, function() { echo "ok 11\n"; ev_break(); });
-$c = new EvTimer(1.9, 0, function() { echo "not ok 11\n"; ev_break(); });
+$a = new EvTimer(1.6, 0, function() { echo "not ok 11\n"; Ev::stop(); });
+$b = new EvTimer(0.3, 0, function() { echo "ok 11\n"; Ev::stop(); });
+$c = new EvTimer(1.9, 0, function() { echo "not ok 11\n"; Ev::stop(); });
 
 echo "ok 10\n";
-ev_run();
+Ev::run();
 echo "ok 12\n";
 ?>
 --EXPECT--

tests/05_timer.phpt

 $fudge = 0.02;
 $id = 1;
 
-$base = ev_now();
-$prev = ev_now();
+$base = Ev::now();
+$prev = Ev::now();
 
 for ($i = 1; $i <= 5; ++$i) {
 	$t = $i * $i * 1.735435336;
 
 	$timer = new EvTimer($t, 0, function ($w, $r)
 		use (&$id, &$prev, $base, $i, $t, $fudge) {
-			$now = ev_now();
+			$now = Ev::now();
 
-			ev_verify();
+			Ev::verify();
 
 			echo $now + $fudge >= $prev ? "" : "not ", "ok ", ++$id,
 				" # t0 $i $now + $fudge >= $prev\n";
 
 	$periodic = new EvPeriodic($base + $t, 0, NULL, function ($w, $r)
 		use (&$id, &$prev, $base, $i, $t) {
-			$now = ev_now();
+			$now = Ev::now();
 
-			ev_verify();
+			Ev::verify();
 
 			echo $now >= $prev ? "" : "not ", "ok ", ++$id,
 				" # p0 $i $now >= $prev\n";
 }
 
 echo "ok 1\n";
-ev_run();
+Ev::run();
 echo "ok 32\n";
 ?>
 --EXPECTF--

tests/06_keepalive.phpt

 $timer->keepalive(1);
 
 echo "ok 1\n";
-ev_run();
+Ev::run();
 echo "ok 2\n";
 
 $timer->start();
 $timer2->keepalive(0);
 
 echo "ok 3\n";
-ev_run(0);
+Ev::run(0);
 echo "ok 5\n";
 
 
 $timer->keepalive(1);
 
 echo "ok 6\n";
-ev_run();
+Ev::run();
 echo "ok 8\n";
 ?>
 --EXPECT--

tests/07_stat.phpt

 	echo FALSE == $w->attr() ? "" : "not ", "ok 9\n";
 	echo FALSE == $w->stat() ? "" : "not ", "ok 10\n";
 
-   	ev_break();
+   	Ev::stop();
 });
 $w->start();
 
 
 $t = new EvTimer(0.2, 0, function ($w, $r) {
 	echo "ok 2\n";
-	ev_break();
+	Ev::stop();
 });
 $t->start();
 
 echo $w->stat() ? "" : "not ", "ok 1\n";
-ev_run();
+Ev::run();
 echo "ok 3\n";
 
 unlink($fh);
 
 $t = new EvTimer(0.2, 0, function ($w, $r) {
 	echo "ok 2\n";
-	ev_break();
+	Ev::stop();
 });
 $t->start();
 
 echo "ok 4\n";
-ev_run();
+Ev::run();
 echo "ok 11\n";
 
 ?>

tests/08_priority.phpt

 $t1 = new EvTimer(-1, 0, function ($w, $r) { echo "ok 3\n"; });
 $t1->priority = 1;
 
-$i2 = new EvIdle(function ($w, $r) { echo ev_iteration() == 1 ? "" : "not ", "ok 2\n"; $w->stop(); });
+$i2 = new EvIdle(function ($w, $r) { echo Ev::iteration() == 1 ? "" : "not ", "ok 2\n"; $w->stop(); });
 $i2->priority = 10;
-$i3 = new EvIdle(function ($w, $r) { echo ev_iteration() == 3 ? "" : "not ", "ok 7\n"; $w->stop(); });
-$i1 = new EvIdle(function ($w, $r) { echo ev_iteration() == 2 ? "" : "not ", "ok 6\n"; $w->stop(); });
+$i3 = new EvIdle(function ($w, $r) { echo Ev::iteration() == 3 ? "" : "not ", "ok 7\n"; $w->stop(); });
+$i1 = new EvIdle(function ($w, $r) { echo Ev::iteration() == 2 ? "" : "not ", "ok 6\n"; $w->stop(); });
 $i1->priority = 1;
-$i_ = new EvIdle(function ($w, $r) { echo ev_iteration() == 4 ? "" : "not ", "ok 8\n"; $w->stop(); });
+$i_ = new EvIdle(function ($w, $r) { echo Ev::iteration() == 4 ? "" : "not ", "ok 8\n"; $w->stop(); });
 $i_->priority = -1;
 
 $t0->start();
 $i_->start();
 
 echo "ok 1\n";
-ev_run();
+Ev::run();
 echo "ok 9\n";
 ?>
 --EXPECT--

tests/09_loop_timer.phpt

 		});
 }
 
-#ev_run();
+#Ev::run();
 print "ok 1\n";
 $l->run();
 print "ok 152\n";
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.