Skip to content

Commit

Permalink
Merge pull request #19 from vuongxuongminh/2.x
Browse files Browse the repository at this point in the history
Update document
  • Loading branch information
vuongxuongminh authored Feb 7, 2021
2 parents b45da46 + 60528c2 commit 2234595
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
37 changes: 33 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,32 @@ This is the contents of the published config file:

```php
return [
/**
/*
* The PHP binary will be use in async processes.
*/
'withBinary' => PHP_BINARY,

/*
* Maximum concurrency async processes.
*/
'concurrency' => 20,

/**
/*
* Async process timeout.
*/
'timeout' => 15,

/**
/*
* Sleep (micro-second) time when waiting async processes.
*/
'sleepTime' => 50000,

/**
/*
* Default output length of async processes.
*/
'defaultOutputLength' => 1024 * 10,

/*
* An autoload script to boot composer autoload and Laravel application.
* Default null meaning using an autoload of this package.
*/
Expand All @@ -69,6 +79,25 @@ After install, now you can try run async code via `Async` facade:
```php
use Async;

for ($i = 1; $i < 20; $i++) {
Async::run(function () use ($i) {
sleep(1);

return $i;
});
}

var_dump(implode(', ', Async::wait()));

// Output value may be like:
// string(65) "5, 2, 1, 14, 4, 6, 7, 8, 19, 16, 12, 18, 13, 3, 10, 9, 11, 17, 15"
```

An async job can be callable class, anonymous function or Laravel callback:

```php
use Async;

// run with anonymous function:
Async::run(function() {
// Do a thing
Expand Down
2 changes: 1 addition & 1 deletion config/async.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

/*
* An autoload script to boot composer autoload and Laravel application.
* Default null meaning using an autoload of async extension.
* Default null meaning using an autoload of this package.
*/
'autoload' => null,
];

0 comments on commit 2234595

Please sign in to comment.