PHP code example of pe / component-loop
1. Go to this page and download the library: Download pe/component-loop library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pe / component-loop example snippets
namespace PE\Component\Loop;
$loop = new Loop();
// For delayed run callable add singular timer
$loop->addSingularTimer(0.1, static function (Loop $loop, Timer $timer) {
// Do some work delayed by 0.1 second
});
// For repeated run callable add periodic timer
$loop->addPeriodicTimer(0.5, static function (Loop $loop, Timer $timer) {
// Do some work at each 0.5 second
});
// For stop loop execution you may add special timer
$loop->addSingularTimer(60, static function (Loop $loop) {
$loop->stop();
});
// Run loop
$loop->run();