10
10
//===----------------------------------------------------------------------===//
11
11
12
12
#if canImport(System)
13
- import System
13
+ @ preconcurrency import System
14
14
#else
15
15
@preconcurrency import SystemPackage
16
16
#endif
@@ -27,10 +27,6 @@ import Musl
27
27
import WinSDK
28
28
#endif
29
29
30
- #if canImport(Synchronization)
31
- import Synchronization
32
- #endif
33
-
34
30
/// An object that repersents a subprocess that has been
35
31
/// executed. You can use this object to send signals to the
36
32
/// child process as well as stream its output and error.
@@ -48,11 +44,8 @@ public final class Execution<
48
44
internal let error : Error
49
45
internal let outputPipe : CreatedPipe
50
46
internal let errorPipe : CreatedPipe
51
- #if canImport(Synchronization)
52
- internal let outputConsumptionState : AtomicBox < Atomic < OutputConsumptionState . RawValue > >
53
- #else
54
- internal let outputConsumptionState : AtomicBox < LockedState < OutputConsumptionState > >
55
- #endif
47
+ internal let outputConsumptionState : AtomicBox
48
+
56
49
#if os(Windows)
57
50
internal let consoleBehavior : PlatformOptions . ConsoleBehavior
58
51
@@ -69,11 +62,7 @@ public final class Execution<
69
62
self . error = error
70
63
self . outputPipe = outputPipe
71
64
self . errorPipe = errorPipe
72
- #if canImport(Synchronization)
73
- self . outputConsumptionState = AtomicBox ( Atomic ( 0 ) )
74
- #else
75
- self . outputConsumptionState = AtomicBox ( LockedState ( OutputConsumptionState ( rawValue: 0 ) ) )
76
- #endif
65
+ self . outputConsumptionState = AtomicBox ( )
77
66
self . consoleBehavior = consoleBehavior
78
67
}
79
68
#else
@@ -89,11 +78,7 @@ public final class Execution<
89
78
self . error = error
90
79
self . outputPipe = outputPipe
91
80
self . errorPipe = errorPipe
92
- #if canImport(Synchronization)
93
- self . outputConsumptionState = AtomicBox ( Atomic ( 0 ) )
94
- #else
95
- self . outputConsumptionState = AtomicBox ( LockedState ( OutputConsumptionState ( rawValue: 0 ) ) )
96
- #endif
81
+ self . outputConsumptionState = AtomicBox ( )
97
82
}
98
83
#endif // os(Windows)
99
84
}
@@ -107,9 +92,9 @@ extension Execution where Output == SequenceOutput {
107
92
/// Accessing this property will **fatalError** if this property was
108
93
/// accessed multiple times. Subprocess communicates with parent process
109
94
/// via pipe under the hood and each pipe can only be consumed once.
110
- public var standardOutput : some AsyncSequence < SequenceOutput . Buffer , any Swift . Error > {
95
+ public var standardOutput : AsyncBufferSequence {
111
96
let consumptionState = self . outputConsumptionState. bitwiseXor (
112
- OutputConsumptionState . standardOutputConsumed,
97
+ OutputConsumptionState . standardOutputConsumed
113
98
)
114
99
115
100
guard consumptionState. contains ( . standardOutputConsumed) ,
@@ -130,9 +115,9 @@ extension Execution where Error == SequenceOutput {
130
115
/// Accessing this property will **fatalError** if this property was
131
116
/// accessed multiple times. Subprocess communicates with parent process
132
117
/// via pipe under the hood and each pipe can only be consumed once.
133
- public var standardError : some AsyncSequence < SequenceOutput . Buffer , any Swift . Error > {
118
+ public var standardError : AsyncBufferSequence {
134
119
let consumptionState = self . outputConsumptionState. bitwiseXor (
135
- OutputConsumptionState . standardOutputConsumed,
120
+ OutputConsumptionState . standardOutputConsumed
136
121
)
137
122
138
123
guard consumptionState. contains ( . standardErrorConsumed) ,
0 commit comments