Skip to content

Commit

Permalink
updates readme
Browse files Browse the repository at this point in the history
  • Loading branch information
denismitr committed May 18, 2018
1 parent aef7bec commit 112dbf1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ composer require denismitr/async-runner

```php
$wg = WaitGroup::create();
$profit = 0;
$counter = 0;

foreach (range(1, 10) as $i) {
$wg->add(function () {
usleep(200); // some action here that takes time
return 5;
})->then(function (int $result) use (&$profit) {
$profit += $result;
})->then(function (int $result) use (&$counter) {
$counter += $result;
});
}

$wg->wait();

echo $profit; // 50
$counter; // 50
```
Example with AsyncTask inheritance
```php
Expand Down

0 comments on commit 112dbf1

Please sign in to comment.