mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-01 09:50:16 +00:00
Add method to post a low memory notification.
This commit is contained in:
1 parent
c91fd29e44
commit
9143eee0c7
1 file changed
+15
@@ -6,9 +6,24 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import os
|
||||
|
||||
public extension Notification.Name {
|
||||
/// Posted when the app should free memory — on background transition
|
||||
/// and potentially on memory warnings. Always posted on the main thread.
|
||||
static let lowMemory = Notification.Name("LowMemoryNotification")
|
||||
}
|
||||
|
||||
private let lowMemoryLogger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "LowMemory")
|
||||
|
||||
public func postLowMemoryNotification() {
|
||||
if Thread.isMainThread {
|
||||
lowMemoryLogger.info("Posting low memory notification")
|
||||
NotificationCenter.default.post(name: .lowMemory, object: nil)
|
||||
} else {
|
||||
Task { @MainActor in
|
||||
lowMemoryLogger.info("Posting low memory notification")
|
||||
NotificationCenter.default.post(name: .lowMemory, object: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user