Bug 1226406 - Part 1: add asynchronous connection and transaction operations to SwiftData.
Bug 1226406 - Part 1: add asynchronous connection and transaction operations to SwiftData.

Run code within a connection scope or transaction, but don't block waiting for it to return.

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.

vbudhram/firefox-ios,doronkatz/firefox-ios,eoger/firefox-ios,justindarc/firefox-ios,Bunn/firefox-ios,brave/browser-ios,Johennes/firefox-ios,serbomjack/Firefox-for-windows-10-mobile,matthewpurcell/firefox-ios,radazzouz/firefox-ios,mshhmzh/firefox-ios,Bunn/firefox-ios,sharath-cliqz/browser-ios,sachin004/firefox-ios,Acidburn0zzz/firefox-ios,vbudhram/firefox-ios,HongliYu/firefox-ios,sachin004/firefox-ios,Johennes/firefox-ios,varkor/firefox-ios,jacobwhite/firefox-ios,serbomjack/Firefox-for-windows-10-mobile,varkor/firefox-ios,garvankeeley/firefox-ios,StYaphet/firefox-ios,flodolo/firefox-ios,jacobwhite/firefox-ios,serbomjack/Firefox-for-windows-10-mobile,Ehrippura/firefox-ios,cliqz-oss/browser-ios,Bunn/firefox-ios,garvankeeley/firefox-ios,st3fan/firefox-ios,jacobwhite/firefox-ios,tecgirl/firefox-ios,vbudhram/firefox-ios,flodolo/firefox-ios,kesun421/firefox-ios,mauryat/firefox-ios,mshhmzh/firefox-ios,tecgirl/firefox-ios,sharath-cliqz/browser-ios,Acidburn0zzz/firefox-ios,flodolo/firefox-ios,sharath-cliqz/browser-ios,radazzouz/firefox-ios,vbudhram/firefox-ios,Johennes/firefox-ios,mozilla-mobile/firefox-ios,Allow2CEO/browser-ios,ncalexan/firefox-ios,st3fan/firefox-ios,shorlander/firefox-ios,matthewpurcell/firefox-ios,serbomjack/Firefox-for-windows-10-mobile,st3fan/firefox-ios,AaronMT/firefox-ios,ilhanadiyaman/firefox-ios,ilhanadiyaman/firefox-ios,Acidburn0zzz/firefox-ios,Ehrippura/firefox-ios,HongliYu/firefox-ios,radazzouz/firefox-ios,Acidburn0zzz/firefox-ios,mozilla-mobile/firefox-ios,doronkatz/firefox-ios,AaronMT/firefox-ios,vbudhram/firefox-ios,StYaphet/firefox-ios,alessiobrozzi/firefox-ios,varkor/firefox-ios,aaronraimist/firefox-ios,kesun421/firefox-ios,brave/browser-ios,serbomjack/Firefox-for-windows-10-mobile,mshhmzh/firefox-ios,cliqz-oss/browser-ios,farhanpatel/firefox-ios,justindarc/firefox-ios,flodolo/firefox-ios,st3fan/firefox-ios,alessiobrozzi/firefox-ios,farhanpatel/firefox-ios,ncalexan/firefox-ios,sharath-cliqz/browser-ios,cliqz-oss/browser-ios,SuPair/firefox-ios,ncalexan/firefox-ios,matthewpurcell/firefox-ios,doronkatz/firefox-ios,brave/browser-ios,varkor/firefox-ios,SuPair/firefox-ios,mshhmzh/firefox-ios,Ehrippura/firefox-ios,StYaphet/firefox-ios,mkaply/firefox-ios,doronkatz/firefox-ios,serbomjack/Firefox-for-windows-10-mobile,Bunn/firefox-ios,garvankeeley/firefox-ios,StYaphet/firefox-ios,doronkatz/firefox-ios,radazzouz/firefox-ios,ilhanadiyaman/firefox-ios,Johennes/firefox-ios,tecgirl/firefox-ios,justindarc/firefox-ios,tecgirl/firefox-ios,cliqz-oss/browser-ios,mkaply/firefox-ios,eoger/firefox-ios,luoziyong/firefox-ios,DarrenKong/firefox-ios,eoger/firefox-ios,Johennes/firefox-ios,mauryat/firefox-ios,shorlander/firefox-ios,aaronraimist/firefox-ios,aaronraimist/firefox-ios,luoziyong/firefox-ios,eoger/firefox-ios,varkor/firefox-ios,luoziyong/firefox-ios,mshhmzh/firefox-ios,sachin004/firefox-ios,aaronraimist/firefox-ios,jacobwhite/firefox-ios,mozilla-mobile/firefox-ios,farhanpatel/firefox-ios,sachin004/firefox-ios,matthewpurcell/firefox-ios,matthewpurcell/firefox-ios,Allow2CEO/browser-ios,Acidburn0zzz/firefox-ios,mkaply/firefox-ios,brave/browser-ios,doronkatz/firefox-ios,StYaphet/firefox-ios,mshhmzh/firefox-ios,HongliYu/firefox-ios,HongliYu/firefox-ios,alessiobrozzi/firefox-ios,SuPair/firefox-ios,SuPair/firefox-ios,radazzouz/firefox-ios,mozilla-mobile/firefox-ios,mkaply/firefox-ios,Acidburn0zzz/firefox-ios,cliqz-oss/browser-ios,varkor/firefox-ios,mshhmzh/firefox-ios,Ehrippura/firefox-ios,mauryat/firefox-ios,flodolo/firefox-ios,matthewpurcell/firefox-ios,mauryat/firefox-ios,StYaphet/firefox-ios,mozilla-mobile/firefox-ios,aaronraimist/firefox-ios,eoger/firefox-ios,st3fan/firefox-ios,cliqz-oss/browser-ios,tecgirl/firefox-ios,sachin004/firefox-ios,Allow2CEO/browser-ios,garvankeeley/firefox-ios,justindarc/firefox-ios,shorlander/firefox-ios,jacobwhite/firefox-ios,varkor/firefox-ios,farhanpatel/firefox-ios,ilhanadiyaman/firefox-ios,eoger/firefox-ios,DarrenKong/firefox-ios,luoziyong/firefox-ios,farhanpatel/firefox-ios,SuPair/firefox-ios,Allow2CEO/browser-ios,brave/browser-ios,kesun421/firefox-ios,Bunn/firefox-ios,mkaply/firefox-ios,tecgirl/firefox-ios,st3fan/firefox-ios,ilhanadiyaman/firefox-ios,Allow2CEO/browser-ios,DarrenKong/firefox-ios,mkaply/firefox-ios,sharath-cliqz/browser-ios,sachin004/firefox-ios,mshhmzh/firefox-ios,jacobwhite/firefox-ios,DarrenKong/firefox-ios,garvankeeley/firefox-ios,alessiobrozzi/firefox-ios,StYaphet/firefox-ios,alessiobrozzi/firefox-ios,brave/browser-ios,cliqz-oss/browser-ios,StYaphet/firefox-ios,Allow2CEO/browser-ios,AaronMT/firefox-ios,farhanpatel/firefox-ios,flodolo/firefox-ios,shorlander/firefox-ios,mauryat/firefox-ios,mozilla-mobile/firefox-ios,jacobwhite/firefox-ios,st3fan/firefox-ios,garvankeeley/firefox-ios,kesun421/firefox-ios,justindarc/firefox-ios,tecgirl/firefox-ios,matthewpurcell/firefox-ios,Ehrippura/firefox-ios,AaronMT/firefox-ios,Allow2CEO/browser-ios,kesun421/firefox-ios,Ehrippura/firefox-ios,farhanpatel/firefox-ios,radazzouz/firefox-ios,sachin004/firefox-ios,justindarc/firefox-ios,Acidburn0zzz/firefox-ios,brave/browser-ios,serbomjack/Firefox-for-windows-10-mobile,mkaply/firefox-ios,alessiobrozzi/firefox-ios,justindarc/firefox-ios,HongliYu/firefox-ios,eoger/firefox-ios,Johennes/firefox-ios,ilhanadiyaman/firefox-ios,luoziyong/firefox-ios,SuPair/firefox-ios,DarrenKong/firefox-ios,brave/browser-ios,Johennes/firefox-ios,sachin004/firefox-ios,vbudhram/firefox-ios,tecgirl/firefox-ios,mauryat/firefox-ios,ncalexan/firefox-ios,Bunn/firefox-ios,aaronraimist/firefox-ios,ncalexan/firefox-ios,st3fan/firefox-ios,AaronMT/firefox-ios,SuPair/firefox-ios,garvankeeley/firefox-ios,luoziyong/firefox-ios,kesun421/firefox-ios,cliqz-oss/browser-ios,mozilla-mobile/firefox-ios,DarrenKong/firefox-ios,doronkatz/firefox-ios,Johennes/firefox-ios,AaronMT/firefox-ios,aaronraimist/firefox-ios,AaronMT/firefox-ios,vbudhram/firefox-ios,Bunn/firefox-ios,DarrenKong/firefox-ios,ilhanadiyaman/firefox-ios,Acidburn0zzz/firefox-ios,sharath-cliqz/browser-ios,matthewpurcell/firefox-ios,luoziyong/firefox-ios,ncalexan/firefox-ios,kesun421/firefox-ios,mauryat/firefox-ios,serbomjack/Firefox-for-windows-10-mobile,varkor/firefox-ios,shorlander/firefox-ios,flodolo/firefox-ios,sharath-cliqz/browser-ios,brave/browser-ios,Allow2CEO/browser-ios,sharath-cliqz/browser-ios,alessiobrozzi/firefox-ios,Ehrippura/firefox-ios,aaronraimist/firefox-ios,radazzouz/firefox-ios,shorlander/firefox-ios,HongliYu/firefox-ios,ncalexan/firefox-ios,shorlander/firefox-ios,ilhanadiyaman/firefox-ios,HongliYu/firefox-ios