SerializedDatabase hides its allowsUnsafeTransactions property, and makes it thread-safe by protecting it inside its serialized dispatch queue.
WALSnapshotTransaction always notifies when the reader connection is no longer used, and reuses the "isInsideTransaction" wording.
In the previous implementation, the snapshot pool would use the same reader connections as the database pool. This would create problem with reentrant reads. Let's make things simple, and not share any database connection.
One can create a snapshot from a read-only pool on a non-WAL database, and that's OK. The snaphost still sees an unchanging database content (but other connections can't write).
It used to be rethrowing, but it was then unable to deal with closed databases.
The async version is modified accordingly: it accepts a Result<Database, Error>, instead of a raw Database.
DatabaseMigrator.asyncMigrate is impacted as well: it accepts a Result<Database, Error>, instead of a (Database, Error?) tuple.
Memory management may not be desirable for all
users of GRDB. `DatabasePool.releaseMemory`
creates a barrier which may cause normally fast
readers to block for a long time. If this is not a
desirable tradeoff, the new
`automaticMemoryManagement` flag in
`Configuration` allows you to disable this feature
of GRDB.
I believe this is incorrect: FB9801372 (UIApplication.didReceiveMemoryWarningNotification should not be declared @MainActor)
Meanwhile, just use the string version.
A workaround based on a MainActor-isolated task can't work due to conflict between compiler version and minimum iOS target:
#if compiler(>=5.5) && canImport(_Concurrency)
if #available(...) { // Check for availability of concurrency runtime
Task { @MainActor [weak self] in
NotificationCenter.default.addObserver(..., name: UIApplication.didReceiveMemoryWarningNotification, object: nil)
}
} else {
// IMPOSSIBLE CASE: No access to Task, no access to notification names
}
#else
NotificationCenter.default.addObserver(..., name: UIApplication.didReceiveMemoryWarningNotification, object: nil)
#endif