Files
Joseph Heck 83cecce066 extending the documentation content (#212)
- cleaning up grammar to use present tense and more direct phrasing
- extending documentation coverage

Current state:
```
                | Abstract        | Curated         | Code Listing
Types           | 71% (10/14)     | 64% (9/14)      | 0.0% (0/14)
Members         | 44% (49/111)    | 77% (85/111)    | 0.0% (0/111)
Globals         | 73% (8/11)      | 91% (10/11)     | 9.1% (1/11)
```
2025-09-19 08:31:20 +00:00

45 lines
1.3 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftServiceLifecycle open source project
//
// Copyright (c) 2023 Apple Inc. and the SwiftServiceLifecycle project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftServiceLifecycle project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
/// An async sequence that emits an element once graceful shutdown has been triggered.
///
/// This sequence is a broadcast async sequence and only produces one value and then finishes.
///
/// - Note: This sequence respects cancellation and thus is `throwing`.
@usableFromInline
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
struct AsyncGracefulShutdownSequence: AsyncSequence, Sendable {
@usableFromInline
typealias Element = CancellationWaiter.Reason
@inlinable
init() {}
@inlinable
func makeAsyncIterator() -> AsyncIterator {
AsyncIterator()
}
@usableFromInline
struct AsyncIterator: AsyncIteratorProtocol {
@inlinable
init() {}
@inlinable
func next() async -> Element? {
await CancellationWaiter().wait()
}
}
}