mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
Avoid breaking changes
- Deprecate setupMemoryManagement(application:) - UIApplication is not available on watchOS, so instead of checking against `#if canImport(UIKit)` we use `#if os(iOS)` Signed-off-by: Pakkito <pe@pierlis.com>
This commit is contained in:
1 parent
f07735f05f
commit
eb98f50891
2 files changed
+20
-14
No files matched your search
@@ -137,13 +137,13 @@ public final class DatabasePool: DatabaseWriter {
|
||||
|
||||
// Be a nice iOS citizen, and don't consume too much memory
|
||||
// See https://github.com/groue/GRDB.swift/#memory-management
|
||||
#if canImport(UIKit)
|
||||
setupMemoryManagement()
|
||||
#if os(iOS)
|
||||
setupAutomaticMemoryManagement()
|
||||
#endif
|
||||
}
|
||||
|
||||
deinit {
|
||||
// Undo job done in setupMemoryManagement()
|
||||
// Undo job done in setupAutomaticMemoryManagement()
|
||||
//
|
||||
// https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/index.html#10_11Error
|
||||
// Explicit unregistration is required before iOS 9 and OS X 10.11.
|
||||
@@ -196,8 +196,6 @@ extension DatabasePool {
|
||||
///
|
||||
/// This method blocks the current thread until all database accesses
|
||||
/// are completed.
|
||||
///
|
||||
/// See also setupMemoryManagement(application:)
|
||||
public func releaseMemory() {
|
||||
// Release writer memory
|
||||
writer.sync { $0.releaseMemory() }
|
||||
@@ -208,7 +206,12 @@ extension DatabasePool {
|
||||
}
|
||||
|
||||
|
||||
#if canImport(UIKit)
|
||||
#if os(iOS)
|
||||
@available(*, deprecated, message: "Memory management is now enabled by default. This deprecated method does nothing.")
|
||||
public func setupMemoryManagement(in application: UIApplication) {
|
||||
// No op.
|
||||
}
|
||||
|
||||
/// Listens to UIApplicationDidEnterBackgroundNotification and
|
||||
/// UIApplicationDidReceiveMemoryWarningNotification in order to release
|
||||
/// as much memory as possible.
|
||||
@@ -216,7 +219,7 @@ extension DatabasePool {
|
||||
/// - param application: The UIApplication that will start a background
|
||||
/// task to let the database pool release its memory when the application
|
||||
/// enters background.
|
||||
private func setupMemoryManagement() {
|
||||
private func setupAutomaticMemoryManagement() {
|
||||
let center = NotificationCenter.default
|
||||
center.addObserver(
|
||||
self,
|
||||
|
||||
@@ -43,8 +43,8 @@ public final class DatabaseQueue: DatabaseWriter {
|
||||
|
||||
// Be a nice iOS citizen, and don't consume too much memory
|
||||
// See https://github.com/groue/GRDB.swift/#memory-management
|
||||
#if canImport(UIKit)
|
||||
setupMemoryManagement()
|
||||
#if os(iOS)
|
||||
setupAutomaticMemoryManagement()
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public final class DatabaseQueue: DatabaseWriter {
|
||||
}
|
||||
|
||||
deinit {
|
||||
// Undo job done in setupMemoryManagement()
|
||||
// Undo job done in setupAutomaticMemoryManagement()
|
||||
//
|
||||
// https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/index.html#10_11Error
|
||||
// Explicit unregistration is required before iOS 9 and OS X 10.11.
|
||||
@@ -80,13 +80,16 @@ extension DatabaseQueue {
|
||||
/// Free as much memory as possible.
|
||||
///
|
||||
/// This method blocks the current thread until all database accesses are completed.
|
||||
///
|
||||
/// See also setupMemoryManagement(application:)
|
||||
public func releaseMemory() {
|
||||
writer.sync { $0.releaseMemory() }
|
||||
}
|
||||
|
||||
#if canImport(UIKit)
|
||||
#if os(iOS)
|
||||
@available(*, deprecated, message: "Memory management is now enabled by default. This deprecated method does nothing.")
|
||||
public func setupMemoryManagement(in application: UIApplication) {
|
||||
// No op.
|
||||
}
|
||||
|
||||
/// Listens to UIApplicationDidEnterBackgroundNotification and
|
||||
/// UIApplicationDidReceiveMemoryWarningNotification in order to release
|
||||
/// as much memory as possible.
|
||||
@@ -94,7 +97,7 @@ extension DatabaseQueue {
|
||||
/// - param application: The UIApplication that will start a background
|
||||
/// task to let the database queue release its memory when the application
|
||||
/// enters background.
|
||||
private func setupMemoryManagement() {
|
||||
private func setupAutomaticMemoryManagement() {
|
||||
let center = NotificationCenter.default
|
||||
center.addObserver(
|
||||
self,
|
||||
|
||||
Reference in new issue
Block a user