Allow transactions and database operations to be performed without blocking the calling thread

RESOLVED FIXED in 2.0

Status

()

RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: rnewman, Assigned: rnewman)

Tracking

unspecified
All
iOS

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

3 years ago
This is a little bit of a fork of Bug 1189170.

The current SwiftData withConnection and transaction calls, and their wrappers in BrowserDB, are the worst kind of async -- they block two threads at once!

We call dispatch_sync to hand a block over to the connection's queue.

That means we wait for the current queue contents to finish running, run the block, and then finally return from the caller.

And very often what we do after that is return a Deferred or invoke some UI callback.

In those cases, there's really no reason to use dispatch_sync; we can have the callback do the right thing, such as filling the Deferred. The calling code can roll right on and do what it likes, chaining off the Deferred if it needs the result.
(Assignee)

Comment 1

3 years ago
Created attachment 8689781 [details] [review]
Link to Github pull-request: https://github.com/mozilla/firefox-ios/pull/1284
Attachment #8689781 - Flags: review?(sleroux)
Attachment #8689781 - Flags: review?(bnicholson)
Comment on attachment 8689781 [details] [review]
Link to Github pull-request: https://github.com/mozilla/firefox-ios/pull/1284

Makes sense, though I noticed you aren't actually using synchronous = false anywhere. Just groundwork for bug 1189170?
Attachment #8689781 - Flags: review?(bnicholson) → review+
(Assignee)

Comment 4

3 years ago
0824db3
(Assignee)

Updated

3 years ago
Blocks: 1201110
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 2.0
Attachment #8689781 - Flags: review?(sleroux)
You need to log in before you can comment on or make changes to this bug.