Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRDB 7: Sendable database accesses #1618

Merged
merged 14 commits into from
Sep 14, 2024
Merged

Conversation

groue
Copy link
Owner

@groue groue commented Sep 8, 2024

No description provided.

We should be able to use sending closures instead, but DispatchQueue.async does not accept sending closures yet.
We should be able to use sending closures instead, but DispatchQueue.async does not accept sending closures yet.
It can be called at any time, when the publisher is subscribed.
We should be able to use a sending closure instead, but DispatchQueue.async does not accept sending closures yet.
…osure

We should be able to use a sending closure instead, but DispatchQueue.async does not accept sending closures yet.
We should be able to use sending closures instead, but DispatchQueue.async does not accept sending closures yet.
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.
@groue groue merged commit 4f1587a into GRDB7 Sep 14, 2024
8 checks passed
@groue groue deleted the dev/GRDB7-Sendable-database-access branch September 14, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant