Skip to content

Commit a600dd3

Browse files
example imports and opens
1 parent 0e41672 commit a600dd3

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

Manual/IO/Async.lean

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ import Std.Async
421421
import Std.Sync.Channel
422422
```
423423
```lean -show
424-
open Std
424+
open Std Async
425425
```
426426
{name}`Selectable.tryOne` checks whether any selector has already resolved and returns the corresponding value immediately, or {name}`none` if none has, rather than blocking.
427427
Defining selection with `:=` rather than `←` makes `pick` the {name}`Async` computation itself rather than its result, so the same poll can be run more than once.
@@ -451,7 +451,7 @@ import Std.Async
451451
import Std.Sync.Channel
452452
```
453453
```lean -show
454-
open Std
454+
open Std Async
455455
```
456456
A {name}`CloseableChannel` provides a selector via {name}`CloseableChannel.recvSelector` that resolves when the channel receives a value.
457457
{name}`Selector.sleep` is a selector that resolves after the specified number of milliseconds have passed.
@@ -486,7 +486,7 @@ import Std.Async
486486
import Std.Sync.Channel
487487
```
488488
```lean -show
489-
open Std
489+
open Std Async
490490
```
491491
A {name}`CloseableChannel` provides a selector via {name}`CloseableChannel.recvSelector` that resolves when the channel receives a value.
492492
The function {name}`recv2` selects the first value returned on either channel:
@@ -623,6 +623,12 @@ This two-phase protocol ensures that there is no data loss, because selectors on
623623
{docstring Waiter.checkFinished}
624624

625625
:::example "Natural Number Ticker"
626+
```imports -show
627+
import Std.Async
628+
```
629+
```lean -show
630+
open Std.Async
631+
```
626632

627633
A {name}`natTicker` is a selector that makes a {name}`Nat` available every 100 milliseconds, incrementing each time.
628634
Its state is determined by two values:

0 commit comments

Comments
 (0)