Commit Graph
234 Commits
Author SHA1 Message Date
Gwendal Roué ac1e5e66be Remove assertion about SQLite snapshot ordering
Fix #1883
2026-09-26 10:20:32 +02:00
Gwendal Roué 21b1322e05 Fix Swiftlint warnings 2026-02-15 15:09:40 +01:00
bellebethcooper 67ebcb325c Minor typo in doc comments 2026-02-03 16:32:37 +11:00
Gwendal Roué 361a482b1e Enable SQLITE_ENABLE_SNAPSHOT by default and introduce SQLITE_DISABLE_SNAPSHOT 2025-10-12 14:03:09 +02:00
Gwendal Roué b1b83abd8b Simplify the compiler checks for the availability of SQLite snapshots 2025-10-04 14:15:13 +02:00
Gwendal Roué 1a3842e4bc Combine and concurrency: lol 2025-09-10 07:12:53 +02:00
Gwendal Roué f435715f75 ValueReducer is SendableMetatype
ValueReducer does not support isolated conformances: it must be able to reduce observed values when needed. This can happen in a nonisolated fashion.
2025-09-10 07:12:52 +02:00
Gwendal Roué 96d04716c2 Update more documentation with the closure syntax 2025-05-11 10:57:20 +02:00
Gwendal Roué 073682c4f0 Remove the experimental flag on stabilized apis 2024-09-28 14:41:12 +02:00
Gwendal Roué 6b2ccebad3 AsyncValueObservation is Sendable
A Sendable async sequences plays well with apple/swift-async-algorithms
2024-09-28 13:36:40 +02:00
Gwendal Roué 900180dafd [BREAKING] Prefer any DatabaseReader and DatabaseWriter 2024-09-21 16:50:03 +02:00
Gwendal Roué 46e15616a7 [BREAKING] macOS 10.15+ 2024-09-21 14:28:24 +02:00
Gwendal Roué e4a4735494 [BREAKING] tvOS 13+ 2024-09-21 13:57:35 +02:00
Gwendal Roué 8c40592955 [BREAKING] iOS 13+ 2024-09-21 13:57:23 +02:00
Gwendal Roué 58a2e04736 Mark ValueObservation starting methods as @preconcurrency
I guess the compiler will learn to stop emitting warnings eventually.

https://mjtsai.com/blog/2024/09/20/unwanted-swift-concurrency-checking/
2024-09-21 12:30:38 +02:00
Gwendal Roué bdb7d84086 [BREAKING] ValueObservation MainActor scheduling
Breaking because before iOS 13, macOS 10.15, tvOS 13, there is no longer any default scheduler
2024-09-21 12:30:38 +02:00
Gwendal Roué e1a384009a [BREAKING] Async sequences built from ValueObservation schedule values and errors on the cooperative thread pool by default. 2024-09-21 12:19:39 +02:00
Gwendal Roué 29f8aa38fb Fix compiler warnings in ValueObservation observers 2024-09-15 12:10:10 +02:00
Gwendal Roué 2f240fd764 [SENDING REGRET] Async database access methods return Sendable results
We can not tell the compiler that we can safely return `sending` results, because fetched values are in the same region as the `db` argument, according to SE-0414 (https://github.com/swiftlang/swift-evolution/blob/main/proposals/0414-region-based-isolation.md#rules-for-merging-isolation-regions).

```
class NotSendable { init() { } }
func fetchNotSendable(_ db: Database) -> NotSendable { fatalError() }

func notOK<T>(_ make: (Database) -> sending T) { }
func ok<T>(_ make: () -> sending T) { }

func usage() {
    ok { NotSendable() }

    // Returning a task-isolated 'NotSendable' value as a 'sending' result
    // risks causing data races.
    notOK { db in fetchNotSendable(db) }
}
```

Various attempts at modifying all fetching methods so that they have a `sending` return value have failed.
2024-09-08 16:55:25 +02:00
Gwendal Roué ec5b7d96e2 SharedValueObservation is Sendable 2024-09-08 16:17:51 +02:00
Gwendal Roué 5f384a4b22 ValueObservation is Sendable 2024-09-08 16:17:51 +02:00
Gwendal Roué 0b6ac870e2 [SENDING REGRET] ValueObservationScheduler requires Sendable closures
We should be able to use sending closures instead, but DispatchQueue.async does not accept sending closures yet.
2024-09-08 16:09:10 +02:00
Gwendal Roué c08b1fa7d5 ValueObservationScheduler is Sendable 2024-08-31 09:58:15 +02:00
Gwendal Roué 849bba2820 Refactor ValueReducer for Swift concurrency
The fetching facet of a ValueReducer is Sendable.
2024-08-27 08:31:28 +02:00
Gwendal Roué c56b52980a DatabaseCancellable is Sendable 2024-08-27 08:05:26 +02:00
Gwendal Roué cc5798cf1e WALSnapshotTransaction is Sendable 2024-08-26 08:27:34 +02:00
Gwendal Roué e72a37d7d5 Rename LockedBox to Mutex 2024-08-25 12:40:28 +02:00
Gwendal Roué 6157a40dad Fix DocC warnings 2024-08-24 16:34:35 +02:00
Gwendal Roué 79cb862478 [BREAKING] watchOS 7+
Rationale: https://github.com/groue/GRDB.swift/issues/1472#issuecomment-1960696836
2024-08-24 15:45:38 +02:00
Gwendal Roué 8caf31296f [BREAKING] Xcode 16+, Swift 6+ 2024-08-24 15:43:09 +02:00
Gwendal Roué 263a549c21 Test that a cancelled ValueObservation does not notify of changes that were enqueued before cancellation.
This is a test for #1550
2024-06-08 13:47:21 +02:00
Gwendal Roué c8bb0a4799 Improve the documentation about the scheduling of ValueObservation fetches 2024-04-21 14:42:47 +02:00
Gwendal Roué 43ced9b2f0 Trivial Sendable conformances
Either added, either made explicitly unavailable.
2024-03-17 18:25:04 +01:00
Gwendal Roué f5d55cb1a1 TODO 2024-01-17 10:51:42 +01:00
Gwendal Roué dff7971cd7 Fix failing test for ValueObservation and Database.notifyChanges(in:) 2023-11-25 15:32:35 +01:00
Gwendal Roué 3a1c211746 Address #1389 by forcing the user to specify a tracked region
This is technically a breaking change, but nobody will notice it.
2023-06-08 12:17:27 +02:00
Gwendal Roué 725d4a3fba When a wal snapshot can't be created, ValueConcurrentObserver fallbacks to plain reads
This commit fixes #1383
2023-06-01 20:00:04 +02:00
Gwendal Roué 65c803a110 Fix #1362 2023-04-29 13:24:46 +02:00
Gwendal Roué d07e8bd3a0 The scenario that leads to the #1362 deadlock 2023-04-18 18:22:47 +02:00
Matt Gallagher c159638498 A test demonstrating deadlock when observer count exceeds size of DatabasePool. 2023-04-18 12:48:06 +10:00
Gwendal Roué d5f38a6a24 Fix Swiftlint warning 2023-04-17 19:17:50 +02:00
Gwendal Roué fcfd6e9028 ValueConcurrentObserver releases its initial WAL transaction earlier 2023-04-15 11:59:19 +02:00
Gwendal Roué 5d9b9edfe1 Fix asyncWALSnapshotTransaction usage.
We must use its result asynchronously.
2023-03-19 12:39:48 +01:00
Gwendal Roué d64274474b ValueObservation: stop creating a new connection on start
Since #1248, ValueObservation on DatabasePool creates a new database connection when it starts. #1256 has revealed that opening a connection can take too much time, which unfortunate consequences: the first value is notified too late, and we block the main thread when the observation is started in the `.immediate` scheduling :-/

In this commit, ValueObservation on DatabasePool just uses one of the available readers, thus avoiding creating a new connection.

When WAL snapshots are available, a long-running read-only transaction is kept opened on this reader, until we can start observing the write transactions, compare database versions, and perform a fetch+notification if and only if the database was modified.

When WAL snapshots are not available (Xcode 14.0 and macOS, or specific SQLCipher or SQLite builds), a double notification of the initial value is always performed, since we can't prove that the database was not changed between the initial fetch and the write access.
2023-03-17 13:52:29 +01:00
Gwendal Roué a0ed1bfd33 Move ValueObservation documentation in an extension file 2023-03-15 16:51:46 +01:00
Gwendal Roué aff924a72b Upgrade Swiftlint and fix warnings 2023-02-04 11:23:14 +01:00
Gwendal Roué ac214e6760 SE-0345: if let shorthand for shadowing an existing optional variable 2023-01-30 08:00:47 +01:00
Gwendal Roué d3c289a320 Availability checks cleanup 2023-01-22 12:37:40 +01:00
baegteun a9feac1339 ♻️ :: OSX -> macOS in Availability Check 2023-01-17 13:58:37 +09:00
Gwendal Roué 0dd17a9a16 Turn ValueObservationScheduler into a protocol 2022-12-29 12:38:06 +01:00