32
32
// alterations made to better cater for the PusherSwift use case
33
33
//
34
34
35
- open class TaskQueue : CustomStringConvertible {
35
+ internal class TaskQueue : CustomStringConvertible {
36
36
public typealias ClosureNoResultNext = ( ) -> Void
37
37
public typealias ClosureWithResultNext = ( Any ? , @escaping ( Any ? ) -> Void ) -> Void
38
38
39
- open var tasks = [ ClosureWithResultNext] ( )
40
- open lazy var completions = [ ClosureNoResultNext] ( )
39
+ internal var tasks = [ ClosureWithResultNext] ( )
40
+ internal lazy var completions = [ ClosureNoResultNext] ( )
41
41
42
42
fileprivate( set) var numberOfActiveTasks = 0
43
- open var maximumNumberOfActiveTasks = 1 {
43
+ internal var maximumNumberOfActiveTasks = 1 {
44
44
willSet {
45
45
assert ( maximumNumberOfActiveTasks > 0 , " Setting less than 1 task at a time is not allowed " )
46
46
}
@@ -51,22 +51,22 @@ open class TaskQueue: CustomStringConvertible {
51
51
52
52
fileprivate( set) var running = false
53
53
54
- open var paused : Bool = false {
54
+ internal var paused : Bool = false {
55
55
didSet {
56
56
running = !paused
57
57
}
58
58
}
59
59
60
60
fileprivate var cancelled = false
61
- open func cancel( ) {
61
+ internal func cancel( ) {
62
62
cancelled = true
63
63
}
64
64
65
65
fileprivate var hasCompletions = false
66
66
67
- public init ( ) { }
67
+ internal init ( ) { }
68
68
69
- open func run( _ completion: ClosureNoResultNext ? = nil ) {
69
+ internal func run( _ completion: ClosureNoResultNext ? = nil ) {
70
70
if completion != nil {
71
71
hasCompletions = true
72
72
completions += [ completion!]
@@ -154,21 +154,21 @@ open class TaskQueue: CustomStringConvertible {
154
154
}
155
155
}
156
156
157
- open func skip( ) {
157
+ internal func skip( ) {
158
158
if tasks. count> 0 {
159
159
_ = tasks. remove ( at: 0 )
160
160
}
161
161
}
162
162
163
- open func removeAll( ) {
163
+ internal func removeAll( ) {
164
164
tasks. removeAll ( keepingCapacity: false )
165
165
}
166
166
167
- open var count : Int {
167
+ internal var count : Int {
168
168
return tasks. count
169
169
}
170
170
171
- open func retry( _ delay: Double = 0 ) {
171
+ internal func retry( _ delay: Double = 0 ) {
172
172
assert ( maximumNumberOfActiveTasks == 1 , " You can only call retry() only on serial queues " )
173
173
174
174
tasks. insert ( currentTask!, at: 0 )
@@ -180,7 +180,7 @@ open class TaskQueue: CustomStringConvertible {
180
180
}
181
181
}
182
182
183
- open var description : String {
183
+ internal var description : String {
184
184
let state = running ? " runing " : ( paused ? " paused " : " stopped " )
185
185
let type = maximumNumberOfActiveTasks == 1 ? " serial " : " parallel "
186
186
@@ -202,14 +202,14 @@ open class TaskQueue: CustomStringConvertible {
202
202
//
203
203
// Add a task closure with result and next params
204
204
//
205
- public func += ( tasks: inout [ TaskQueue . ClosureWithResultNext ] , task: @escaping TaskQueue . ClosureWithResultNext ) {
205
+ internal func += ( tasks: inout [ TaskQueue . ClosureWithResultNext ] , task: @escaping TaskQueue . ClosureWithResultNext ) {
206
206
tasks += [ task]
207
207
}
208
208
209
209
//
210
210
// Add a task closure that doesn't take result/next params
211
211
//
212
- public func += ( tasks: inout [ TaskQueue . ClosureWithResultNext ] , task: @escaping TaskQueue . ClosureNoResultNext ) {
212
+ internal func += ( tasks: inout [ TaskQueue . ClosureWithResultNext ] , task: @escaping TaskQueue . ClosureNoResultNext ) {
213
213
tasks += [ { _, next in
214
214
task ( )
215
215
next ( nil )
0 commit comments