mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
fix: fixed a few data races that prevent correct widget activation (#1605)
This commit is contained in:
@@ -23,8 +23,6 @@ public protocol Reader_p {
|
||||
func read()
|
||||
func terminate()
|
||||
|
||||
func getValue<T>() -> T
|
||||
|
||||
func start()
|
||||
func pause()
|
||||
func stop()
|
||||
@@ -62,7 +60,6 @@ open class Reader<T: Codable>: NSObject, ReaderInternal_p {
|
||||
|
||||
private var repeatTask: Repeater?
|
||||
private var nilCallbackCounter: Int = 0
|
||||
private var ready: Bool = false
|
||||
private var locked: Bool = true
|
||||
private var initlizalized: Bool = false
|
||||
|
||||
@@ -78,6 +75,16 @@ open class Reader<T: Codable>: NSObject, ReaderInternal_p {
|
||||
}
|
||||
}
|
||||
|
||||
private var _ready: Bool = false
|
||||
public var ready: Bool {
|
||||
get {
|
||||
self.variablesQueue.sync { self._ready }
|
||||
}
|
||||
set {
|
||||
self.variablesQueue.sync { self._ready = newValue }
|
||||
}
|
||||
}
|
||||
|
||||
public init(_ module: ModuleType, popup: Bool = false) {
|
||||
self.popup = popup
|
||||
|
||||
@@ -180,10 +187,6 @@ open class Reader<T: Codable>: NSObject, ReaderInternal_p {
|
||||
}
|
||||
|
||||
extension Reader: Reader_p {
|
||||
public func getValue<T>() -> T {
|
||||
return self.value as! T
|
||||
}
|
||||
|
||||
public func lock() {
|
||||
self.locked = true
|
||||
}
|
||||
|
||||
@@ -371,7 +371,6 @@ public class MenuBar {
|
||||
|
||||
private var moduleName: String
|
||||
private var menuBarItem: NSStatusItem? = nil
|
||||
private var active: Bool = false
|
||||
private var queue: DispatchQueue
|
||||
|
||||
private var combinedModules: Bool {
|
||||
@@ -393,6 +392,16 @@ public class MenuBar {
|
||||
}
|
||||
}
|
||||
|
||||
private var _active: Bool = false
|
||||
public var active: Bool {
|
||||
get {
|
||||
self.queue.sync { self._active }
|
||||
}
|
||||
set {
|
||||
self.queue.sync { self._active = newValue }
|
||||
}
|
||||
}
|
||||
|
||||
init(moduleName: String) {
|
||||
self.moduleName = moduleName
|
||||
self.queue = DispatchQueue(label: "eu.exelban.Stats.MenuBar.\(moduleName)")
|
||||
|
||||
Reference in New Issue
Block a user