xref: /php-uv/examples/timer.php (revision 99312394)
1<?php
2$loop = uv_default_loop();
3$timer = uv_timer_init();
4
5$i = 0;
6uv_timer_start($timer, 1000, 1000, function($stat) use (&$i, $timer, $loop) {
7    echo "count: {$i}" . PHP_EOL;
8    $i++;
9
10    if ($i > 3) {
11        uv_timer_stop($timer);
12        uv_unref($timer);
13    }
14});
15
16uv_run();
17
18echo "finished\n";
19