Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -392,7 +392,7 @@ $promise->then(function (int $bytes) {
});
```

## delay()
### delay()

The `delay(float $seconds): void` function can be used to
delay program execution for duration given in `$seconds`.
Expand DownExpand Up@@ -421,7 +421,7 @@ same loop until the delay returns:

```php
echo 'a';
Loop::addTimer(1.0, function () {
Loop::addTimer(1.0, function (): void {
echo 'b';
});
React\Async\delay(3.0);
Expand DownExpand Up@@ -453,13 +453,13 @@ Everything inside this function will still be blocked, but everything outside
this function can be executed asynchronously without blocking:

```php
Loop::addTimer(0.5, React\Async\async(function () {
Loop::addTimer(0.5, React\Async\async(function (): void {
echo 'a';
React\Async\delay(1.0);
echo 'c';
}));

Loop::addTimer(1.0, function () {
Loop::addTimer(1.0, function (): void {
echo 'b';
});

Expand All@@ -481,13 +481,13 @@ promise will clean up any pending timers and throw a `RuntimeException` from
the pending delay which in turn would reject the resulting promise.

```php
$promise = async(function () {
$promise = async(function (): void {
echo 'a';
delay(3.0);
echo 'b';
});
})();

Loop::addTimer(2.0, function () use ($promise) {
Loop::addTimer(2.0, function () use ($promise): void {
$promise->cancel();
});

Expand Down
12 changes: 6 additions & 6 deletions src/functions.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -384,7 +384,7 @@ function (mixed $throwable) use (&$rejected, &$rejectedThrowable, &$fiber, $lowL
*
* ```php
* echo 'a';
* Loop::addTimer(1.0, function () {
* Loop::addTimer(1.0, function (): void {
* echo 'b';
* });
* React\Async\delay(3.0);
Expand DownExpand Up@@ -416,13 +416,13 @@ function (mixed $throwable) use (&$rejected, &$rejectedThrowable, &$fiber, $lowL
* this function can be executed asynchronously without blocking:
*
* ```php
* Loop::addTimer(0.5, React\Async\async(function () {
* Loop::addTimer(0.5, React\Async\async(function (): void {
* echo 'a';
* React\Async\delay(1.0);
* echo 'c';
* }));
*
* Loop::addTimer(1.0, function () {
* Loop::addTimer(1.0, function (): void {
* echo 'b';
* });
*
Expand All@@ -444,13 +444,13 @@ function (mixed $throwable) use (&$rejected, &$rejectedThrowable, &$fiber, $lowL
* the pending delay which in turn would reject the resulting promise.
*
* ```php
* $promise = async(function () {
* $promise = async(function (): void {
* echo 'a';
* delay(3.0);
* echo 'b';
* });
* })();
*
* Loop::addTimer(2.0, function () use ($promise) {
* Loop::addTimer(2.0, function () use ($promise): void {
* $promise->cancel();
* });
*
Expand Down