Skip to content

Commit

Permalink
rename swift-timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
swhitty committed Sep 8, 2024
1 parent ad20f4a commit 1ea7c8e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Test
run: swift test --enable-code-coverage --skip-build
- name: Gather code coverage
run: xcrun llvm-cov export -format="lcov" .build/debug/TaskTimeoutPackageTests.xctest/Contents/MacOS/TaskTimeoutPackageTests -instr-profile .build/debug/codecov/default.profdata > coverage_report.lcov
run: xcrun llvm-cov export -format="lcov" .build/debug/TimeoutPackageTests.xctest/Contents/MacOS/TimeoutPackageTests -instr-profile .build/debug/codecov/default.profdata > coverage_report.lcov
- name: Upload Coverage
uses: codecov/codecov-action@v4
with:
Expand Down
12 changes: 6 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
import PackageDescription

let package = Package(
name: "TaskTimeout",
name: "Timeout",
platforms: [
.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6)
],
products: [
.library(
name: "TaskTimeout",
targets: ["TaskTimeout"]
name: "Timeout",
targets: ["Timeout"]
)
],
targets: [
.target(
name: "TaskTimeout",
name: "Timeout",
path: "Sources",
swiftSettings: .upcomingFeatures
),
.testTarget(
name: "TaskTimeoutTests",
dependencies: ["TaskTimeout"],
name: "TimeoutTests",
dependencies: ["Timeout"],
path: "Tests",
swiftSettings: .upcomingFeatures
)
Expand Down
22 changes: 12 additions & 10 deletions README.md
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()
}
Expand All @@ -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))
6 changes: 3 additions & 3 deletions Sources/TaskTimeout.swift → Sources/Timeout.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//
// TaskTimeout.swift
// TaskTimeout
// Timeout.swift
// swift-timeout
//
// Created by Simon Whitty on 31/08/2024.
// Copyright 2024 Simon Whitty
//
// Distributed under the permissive MIT license
// Get the latest version from here:
//
// https://github.com/swhitty/TaskTimeout
// https://github.com/swhitty/swift-timeout
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 5 additions & 5 deletions Tests/TaskTimeoutTests.swift → Tests/TimeoutTests.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//
// TaskTimeoutTests.swift
// TaskTimeout
// TimeoutTests.swift
// swift-timeout
//
// Created by Simon Whitty on 31/08/2024.
// Copyright 2024 Simon Whitty
//
// Distributed under the permissive MIT license
// Get the latest version from here:
//
// https://github.com/swhitty/TaskTimeout
// https://github.com/swhitty/swift-timeout
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -29,10 +29,10 @@
// SOFTWARE.
//

import TaskTimeout
import Timeout
import XCTest

final class TaskTimeoutTests: XCTestCase {
final class TimeoutTests: XCTestCase {

@MainActor
func testMainActor_ReturnsValue() async throws {
Expand Down

0 comments on commit 1ea7c8e

Please sign in to comment.