1
0
mirror of https://github.com/danog/amp.git synced 2025-01-22 21:31:18 +01:00
amp/examples/scheduling.php

24 lines
522 B
PHP
Raw Normal View History

2013-08-05 16:05:08 -04:00
<?php
/**
* examples/scheduling.php
*/
require dirname(__DIR__) . '/autoload.php';
$reactor = (new Alert\ReactorFactory)->select();
$ticker = function() { echo "tick ", time(), PHP_EOL; };
// Execute in the next event loop iteration
$reactor->immediately($ticker);
// Execute every $interval seconds until cancelled
$reactor->repeat($ticker, $interval = 1);
// Execute once after $delay seconds
$reactor->once(function() use ($reactor) { $reactor->stop(); }, $delay = 3);
// Release the hounds!
$reactor->run();