Skip to content

Commit

Permalink
add changelog and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Reasno committed Nov 11, 2019
1 parent 6931f9a commit 9dce299
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [#903](https://github.com/hyperf/hyperf/pull/903) Fixed execute `init-proxy` command can not stop when `hyperf/rpc-client` component exists.
- [#904](https://github.com/hyperf/hyperf/pull/904) Fixed the hooked I/O request does not works in the listener that listening `Hyperf\Framework\Event\BeforeMainServerStart` event.
- [#906](https://github.com/hyperf/hyperf/pull/906) Fixed `port` property of URI of `Hyperf\HttpMessage\Server\Request`.
- [#909](https://github.com/hyperf/hyperf/pull/909) Fixed a issue that causes staled parallel execution.

# v1.1.5 - 2019-11-07

Expand Down
11 changes: 9 additions & 2 deletions doc/zh/coroutine.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ $wg->wait();

```php
<?php
use Hyperf\Utils\Exception\ParallelExecutionException;

$parallel = new \Hyperf\Utils\Parallel();
$parallel->add(function () {
\Hyperf\Utils\Coroutine::sleep(1);
Expand All @@ -164,8 +166,13 @@ $parallel->add(function () {
\Hyperf\Utils\Coroutine::sleep(1);
return \Hyperf\Utils\Coroutine::id();
});
// $result 结果为 [1, 2]
$result = $parallel->wait();
try{
// $results 结果为 [1, 2]
$results = $parallel->wait();
} catch(ParallelExecutionException $e){
//$e->getResults() 获取协程中的返回值。
//$e->getThrowables() 获取协程中出现的异常。
}
```

通过上面的代码我们可以看到仅花了 1 秒就得到了两个不同的协程的 ID,在调用 `add(callable $callable)` 的时候 `Parallel` 类会为之自动创建一个协程,并加入到 `WaitGroup` 的调度去。
Expand Down

0 comments on commit 9dce299

Please sign in to comment.