You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,17 +22,25 @@ To install using Swift Package Manager, add this to the `dependencies:` section
22
22
23
23
# Usage
24
24
25
-
Usage is similar to using structured concurrency:
25
+
Usage is similar to using structured concurrency, provide a closure and a [`ContinousClock.Instant`](https://developer.apple.com/documentation/swift/continuousclock/instant) for when the child task is cancelled and `TimeoutError` is thrown:
26
26
27
27
```swift
28
28
importTimeout
29
29
30
-
let val =tryawaitwithThrowingTimeout(seconds: 1.5) {
30
+
let val =tryawaitwithThrowingTimeout(after: .now+ .seconds(2)) {
31
31
tryawaitperform()
32
32
}
33
33
```
34
34
35
-
If the timeout expires before a value is returned the task is cancelled and `TimeoutError` is thrown.
35
+
`TimeInterval` can also be provided:
36
+
37
+
```swift
38
+
let val =tryawaitwithThrowingTimeout(seconds: 2.0) {
39
+
tryawaitperform()
40
+
}
41
+
```
42
+
43
+
When deadline is reached the task executing the closure is cancelled and `TimeoutError` is thrown.
0 commit comments