PHP code example of zver / async
1. Go to this page and download the library: Download zver/async 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/ */
zver / async example snippets
//create runner
$runner = new AsyncRunner();
for ($i = 0; $i < $count; $i++) {
//add some task class
$runner->addTask(new AsyncRunnerTestTask($i));
}
//wait for results
$results = $runner->runAndWait();
//or run in manual mode
$runner->run();
while (!$runner->isCompleted()) {
$runner->iterate();
}
$results = $runner->getResults();
class AsyncRunnerTestTask extends AsyncTask
{
public function configure()
{
//prepare for something
}
public function run()
{
//do something
}
}