-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
27 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
[![Build](https://github.com/swhitty/TaskTimeout/actions/workflows/build.yml/badge.svg)](https://github.com/swhitty/TaskTimeout/actions/workflows/build.yml) | ||
[![Codecov](https://codecov.io/gh/swhitty/TaskTimeout/graphs/badge.svg)](https://codecov.io/gh/swhitty/TaskTimeout) | ||
[![Platforms](https://img.shields.io/badge/platforms-iOS%20|%20Mac%20|%20tvOS%20|%20Linux%20|%20Windows-lightgray.svg)](https://github.com/swhitty/TaskTimeout/blob/main/Package.swift) | ||
[![Build](https://github.com/swhitty/swift-timeout/actions/workflows/build.yml/badge.svg)](https://github.com/swhitty/swift-timeout/actions/workflows/build.yml) | ||
[![Codecov](https://codecov.io/gh/swhitty/swift-timeout/graphs/badge.svg)](https://codecov.io/gh/swhitty/swift-timeout) | ||
[![Platforms](https://img.shields.io/badge/platforms-iOS%20|%20Mac%20|%20tvOS%20|%20Linux%20|%20Windows-lightgray.svg)](https://github.com/swhitty/swift-timeout/blob/main/Package.swift) | ||
[![Swift 6.0](https://img.shields.io/badge/swift-5.10%20–%206.0-red.svg?style=flat)](https://developer.apple.com/swift) | ||
[![License](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT) | ||
[![Twitter](https://img.shields.io/badge/[email protected])](http://twitter.com/simonwhitty) | ||
|
||
# Introduction | ||
|
||
**TaskTimeout** is a lightweight wrapper around [`ThrowingTaskGroup`](https://developer.apple.com/documentation/swift/throwingtaskgroup) that executes a closure with a given timeout. | ||
**swift-timeout** is a lightweight wrapper around [`Task`](https://developer.apple.com/documentation/swift/task) that executes a closure with a given timeout. | ||
|
||
# Installation | ||
|
||
TaskTimeout can be installed by using Swift Package Manager. | ||
Timeout can be installed by using Swift Package Manager. | ||
|
||
**Note:** TaskTimeout requires Swift 5.10 on Xcode 15.4+. It runs on iOS 13+, tvOS 13+, macOS 10.15+, Linux and Windows. | ||
**Note:** Timeout requires Swift 5.10 on Xcode 15.4+. It runs on iOS 13+, tvOS 13+, macOS 10.15+, Linux and Windows. | ||
To install using Swift Package Manager, add this to the `dependencies:` section in your Package.swift file: | ||
|
||
```swift | ||
.package(url: "https://github.com/swhitty/TaskTimeout.git", .upToNextMajor(from: "0.1.0")) | ||
.package(url: "https://github.com/swhitty/swift-timeout.git", .upToNextMajor(from: "0.2.0")) | ||
``` | ||
|
||
# Usage | ||
|
||
Usage is similar to using task groups: | ||
Usage is similar to using structured concurrency: | ||
|
||
```swift | ||
import Timeout | ||
|
||
let val = try await withThrowingTimeout(seconds: 1.5) { | ||
try await perform() | ||
} | ||
|
@@ -34,6 +36,6 @@ If the timeout expires before a value is returned the task is cancelled and `Tim | |
|
||
# Credits | ||
|
||
TaskTimeout is primarily the work of [Simon Whitty](https://github.com/swhitty). | ||
Timeout is primarily the work of [Simon Whitty](https://github.com/swhitty). | ||
|
||
([Full list of contributors](https://github.com/swhitty/TaskTimeout/graphs/contributors)) | ||
([Full list of contributors](https://github.com/swhitty/swift-timeout/graphs/contributors)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters