Skip to content

Commit

Permalink
Use block before require
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Jan 25, 2025
1 parent 94e3525 commit a9b714f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ Low-level suspension and resumption of coroutines is handled by Revolt's [`Suspe
```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Revolt\EventLoop;

require __DIR__ . '/vendor/autoload.php';

$suspension = EventLoop::getSuspension();

EventLoop::delay(5, function () use ($suspension): void {
Expand All @@ -121,18 +121,16 @@ Callbacks registered on the Revolt event-loop are automatically run as coroutine

require __DIR__ . '/vendor/autoload.php';

use function Amp\delay;

Amp\async(function () {
print '++ Executing callback passed to async()' . PHP_EOL;

delay(3);
Amp\delay(3);

print '++ Finished callback passed to async()' . PHP_EOL;
});

print '++ Suspending to event loop...' . PHP_EOL;
delay(5);
Amp\delay(5);

print '++ Script end' . PHP_EOL;
```
Expand Down Expand Up @@ -195,12 +193,12 @@ retrieve multiple HTTP resources concurrently:
```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Amp\Future;
use Amp\Http\Client\HttpClientBuilder;
use Amp\Http\Client\Request;

require __DIR__ . '/vendor/autoload.php';

$httpClient = HttpClientBuilder::buildDefault();
$uris = [
"google" => "https://www.google.com",
Expand Down Expand Up @@ -286,11 +284,11 @@ associated `Future` to its caller.
```php
<?php // Example async producer using DeferredFuture

require __DIR__ . '/vendor/autoload.php';

use Amp\Future;
use Revolt\EventLoop;

require __DIR__ . '/vendor/autoload.php';

function asyncMultiply(int $x, int $y): Future
{
$deferred = new Amp\DeferredFuture;
Expand Down
4 changes: 2 additions & 2 deletions examples/cancellation.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

require __DIR__ . '/../vendor/autoload.php';

use Amp\CancelledException;
use Amp\TimeoutCancellation;
use function Amp\async;
use function Amp\delay;

require __DIR__ . '/../vendor/autoload.php';

$future = async(function () {
delay(1);

Expand Down

0 comments on commit a9b714f

Please sign in to comment.