fix
This commit is contained in:
parent
aaa1b3812d
commit
ee6362a254
@ -79,7 +79,7 @@ public class SDLContext: @unchecked Sendable {
|
|||||||
private var flowTracer = SDLFlowTracerActor()
|
private var flowTracer = SDLFlowTracerActor()
|
||||||
private var flowTracerCancel: AnyCancellable?
|
private var flowTracerCancel: AnyCancellable?
|
||||||
|
|
||||||
public init(provider: NEPacketTunnelProvider, config: SDLConfiguration, rsaCipher: RSACipher, aesCipher: AESCipher) throws {
|
public init(provider: NEPacketTunnelProvider, config: SDLConfiguration, rsaCipher: RSACipher, aesCipher: AESCipher) {
|
||||||
self.config = config
|
self.config = config
|
||||||
self.rsaCipher = rsaCipher
|
self.rsaCipher = rsaCipher
|
||||||
self.aesCipher = aesCipher
|
self.aesCipher = aesCipher
|
||||||
|
|||||||
@ -8,14 +8,15 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
// 计数器,用来统计qps
|
// 计数器,用来统计qps
|
||||||
class SDLQPSCounter {
|
class SDLQPSCounter: @unchecked Sendable {
|
||||||
private var count = 0
|
private var count = 0
|
||||||
private let timer: DispatchSourceTimer
|
private let timer: DispatchSourceTimer
|
||||||
private let label: String
|
private let label: String
|
||||||
|
private let queue = DispatchQueue(label: "com.punchnet.qps")
|
||||||
|
|
||||||
init(label: String) {
|
init(label: String) {
|
||||||
self.label = label
|
self.label = label
|
||||||
timer = DispatchSource.makeTimerSource(queue: DispatchQueue(label: "com.yourapp.qps"))
|
timer = DispatchSource.makeTimerSource(queue: queue)
|
||||||
timer.schedule(deadline: .now(), repeating: .seconds(1), leeway: .milliseconds(100))
|
timer.schedule(deadline: .now(), repeating: .seconds(1), leeway: .milliseconds(100))
|
||||||
timer.setEventHandler { [weak self] in
|
timer.setEventHandler { [weak self] in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
@ -26,7 +27,7 @@ class SDLQPSCounter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func increment(num: Int = 1) {
|
func increment(num: Int = 1) {
|
||||||
DispatchQueue(label: "com.yourapp.qps").async {
|
queue.async {
|
||||||
self.count += num
|
self.count += num
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user