From 5a871a9b0c0f4ab9889dfbdcef882f5a0d3cc2fb Mon Sep 17 00:00:00 2001 From: Minh Vuong Date: Sun, 7 Feb 2021 11:22:04 +0700 Subject: [PATCH 1/2] Update doc [skip ci]. --- README.md | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6f2acf5..6ad75d3 100644 --- a/README.md +++ b/README.md @@ -38,24 +38,34 @@ 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. + * Default null meaning using an autoload of async extension. */ 'autoload' => null, ]; @@ -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 From 60528c28643a2e3323a576c752871b90fcbe5f5d Mon Sep 17 00:00:00 2001 From: Minh Vuong Date: Sun, 7 Feb 2021 11:23:31 +0700 Subject: [PATCH 2/2] Update doc [skip ci]. --- README.md | 2 +- config/async.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6ad75d3..b2511a9 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ return [ /* * 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, ]; diff --git a/config/async.php b/config/async.php index 48fea1e..fa72b37 100644 --- a/config/async.php +++ b/config/async.php @@ -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, ];