This repository was archived by the owner on Feb 18, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -28,10 +28,35 @@ public func ==(lhs:Stub, rhs:Stub) -> Bool {
2828 return lhs. uuid == rhs. uuid
2929}
3030
31- var stubs = [ Stub] ( )
32- var registered : Bool = false
31+ class MockingjayStorage {
32+ static let shared = MockingjayStorage ( )
33+
34+ var stubs : [ Stub ] {
35+ get { accessQueue. sync { _stubs } }
36+ set { accessQueue. sync { _stubs = newValue } }
37+ }
38+
39+ var registered : Bool {
40+ get { accessQueue. sync { _registered } }
41+ set { accessQueue. sync { _registered = newValue } }
42+ }
43+
44+ private var _stubs = [ Stub] ( )
45+ private var _registered : Bool = false
46+ private var accessQueue : DispatchQueue { DispatchQueue ( label: " MockingjayStorageQueue " , qos: . default) }
47+ }
3348
3449public class MockingjayProtocol : URLProtocol {
50+ private class var storage : MockingjayStorage { . shared }
51+ private class var stubs : [ Stub ] {
52+ get { storage. stubs }
53+ set { storage. stubs = newValue }
54+ }
55+ private class var registered : Bool {
56+ get { storage. registered }
57+ set { storage. registered = newValue }
58+ }
59+
3560 // MARK: Stubs
3661 fileprivate var enableDownloading = true
3762 fileprivate let operationQueue = OperationQueue ( )
You can’t perform that action at this time.
0 commit comments