1
+ //===----------------------------------------------------------------------===//
2
+ //
3
+ // This source file is part of the SwiftServiceLifecycle open source project
4
+ //
5
+ // Copyright (c) 2023 Apple Inc. and the SwiftServiceLifecycle project authors
6
+ // Licensed under Apache License v2.0
7
+ //
8
+ // See LICENSE.txt for license information
9
+ // See CONTRIBUTORS.txt for the list of SwiftServiceLifecycle project authors
10
+ //
11
+ // SPDX-License-Identifier: Apache-2.0
12
+ //
13
+ //===----------------------------------------------------------------------===//
14
+
1
15
import ServiceLifecycle
2
16
3
17
actor MockService : Service , CustomStringConvertible {
@@ -9,7 +23,7 @@ actor MockService: Service, CustomStringConvertible {
9
23
}
10
24
11
25
let events : AsyncStream < Event >
12
- internal private( set) var hasRun : Bool = false
26
+ private( set) var hasRun : Bool = false
13
27
14
28
private let eventsContinuation : AsyncStream < Event > . Continuation
15
29
@@ -24,18 +38,18 @@ actor MockService: Service, CustomStringConvertible {
24
38
description: String
25
39
) {
26
40
var eventsContinuation : AsyncStream < Event > . Continuation !
27
- self . events = AsyncStream< Event> { eventsContinuation = $0 }
41
+ events = AsyncStream< Event> { eventsContinuation = $0 }
28
42
self . eventsContinuation = eventsContinuation!
29
43
30
44
var pingContinuation : AsyncStream < Void > . Continuation !
31
- self . pings = AsyncStream< Void> { pingContinuation = $0 }
45
+ pings = AsyncStream< Void> { pingContinuation = $0 }
32
46
self . pingContinuation = pingContinuation!
33
47
34
48
self . description = description
35
49
}
36
50
37
51
func run( ) async throws {
38
- self . hasRun = true
52
+ hasRun = true
39
53
40
54
try await withTaskCancellationHandler {
41
55
try await withGracefulShutdownHandler {
@@ -62,10 +76,10 @@ actor MockService: Service, CustomStringConvertible {
62
76
}
63
77
64
78
func resumeRunContinuation( with result: Result < Void , Error > ) {
65
- self . runContinuation? . resume ( with: result)
79
+ runContinuation? . resume ( with: result)
66
80
}
67
81
68
82
nonisolated func sendPing( ) {
69
- self . pingContinuation. yield ( )
83
+ pingContinuation. yield ( )
70
84
}
71
85
}
0 commit comments