@@ -80,119 +80,3 @@ extension Task {
80
80
}
81
81
82
82
}
83
-
84
- // ==== Task Deadlines ---------------------------------------------------------
85
-
86
- extension Task {
87
-
88
- /// Returns the earliest deadline set on the current task.
89
- ///
90
- /// If no deadline was set for the task the `Deadline.distantFuture` is returned,
91
- /// as it is effective in conveying that there still is time remaining and the
92
- /// deadline is not overdue yet.
93
- ///
94
- /// ### Suspension
95
- /// This function returns instantly and will never suspend.
96
- /* @instantaneous */
97
- public static func currentDeadline( ) async -> Deadline {
98
- fatalError ( " \( #function) not implemented yet. " )
99
- }
100
-
101
- /// Execute a code block with a deadline in `interval`.
102
- ///
103
- /// If the current task already has a deadline set that is _prior_
104
- /// to the newly set deadline with this API, that deadline will remain in effect.
105
- ///
106
- /// This allows higher level tasks to set an upper bound on the deadline they
107
- /// are willing cumulatively willing to wait for the entire task to execute,
108
- /// regardless of the inner deadlines of the specific child tasks.
109
- ///
110
- /// Cancellation is co-operative and must be checked for by the operation, e.g.
111
- /// by invoking `Task.checkCancellation`, or `Task.isCancelled`.
112
- ///
113
- /// ### Suspension
114
- /// This function returns instantly and will never suspend.
115
- ///
116
- /// - Parameters:
117
- /// - interval: interval after which (from `now()`) the operation task should
118
- /// be considered cancelled.
119
- /// - operation: the operation to execute
120
- /* @instantaneous */
121
- public static func withDeadline< T> (
122
- in interval: _TimeInterval ,
123
- operation: ( ) async throws -> T
124
- ) async rethrows -> T {
125
- fatalError ( " \( #function) not implemented yet. " )
126
- }
127
-
128
- /// Execute a code block with the passed in deadline (unless a shorter deadline is already set).
129
- ///
130
- /// If the current task already has a deadline set that is _prior_
131
- /// to the newly set deadline with this API, that deadline will remain in effect.
132
- ///
133
- /// This allows higher level tasks to set an upper bound on the deadline they
134
- /// are willing cumulatively willing to wait for the entire task to execute,
135
- /// regardless of the inner deadlines of the specific child tasks.
136
- ///
137
- /// Cancellation is co-operative and must be checked for by the operation, e.g.
138
- /// by invoking `Task.checkCancellation` or `Task.isCancelled`.
139
- ///
140
- /// ### Suspension
141
- /// This function returns instantly and will never suspend.
142
- ///
143
- /// - Parameters:
144
- /// - deadline: the point in time after which the operation task should be
145
- /// considered cancelled.
146
- /// - operation: the operation to execute
147
- /* @instantaneous */
148
- public static func withDeadline< T> (
149
- _ deadline: Deadline ,
150
- operation: ( ) async throws -> T
151
- ) async rethrows -> T {
152
- fatalError ( " \( #function) not implemented yet. " )
153
- }
154
-
155
- /// A deadline is a point in time past-which a task should be considered cancelled.
156
- ///
157
- /// Deadlines function the same was as pure cancellation, in the sense that they
158
- /// are cooperative and require the cancelled (deadline exceeding) task to check
159
- /// for this as it is performing its execution.
160
- ///
161
- /// Generally tasks (or partial tasks) should perform such check before they
162
- /// start executing, however this is not a strict rule, and some tasks may
163
- /// choose to be un-cancellable.
164
- public struct Deadline {
165
- public typealias WallTime = UInt64 // equivalent to DispatchWallTime
166
- internal let time : WallTime
167
-
168
- public init ( at time: WallTime ) {
169
- self . time = time
170
- }
171
-
172
- public static var distantFuture : Self {
173
- . init( at: . max)
174
- }
175
-
176
- public static func `in`( _ interval: _TimeInterval ) -> Self {
177
- // now() + interval
178
- fatalError ( " # \( #function) not implemented yet. " )
179
- }
180
-
181
- /// Returns `true` if the deadline is overdue and deadline should be
182
- /// considered overdue (or "exceeded").
183
- ///
184
- /// If this deadline was related to a `Task`, that task should be considered
185
- /// cancelled if the deadline is overdue.
186
- public var isOverdue : Bool {
187
- !self . hasTimeLeft
188
- }
189
-
190
- /// Returns `true` if the deadline is still pending with respect to "now".
191
- public var hasTimeLeft : Bool {
192
- fatalError ( " \( #function) not implemented yet. " ) // self.hasTimeLeft(until: now())
193
- }
194
-
195
- // TODO: public func hasTimeLeft(until: DispatchWallTime or whichever time type we'll use) -> Bool
196
-
197
- }
198
- }
0 commit comments