On Friday, June 10, 2016 at 3:35:42 PM UTC-7, Jens Alfke wrote: > > On Jun 10, 2016, at 3:07 PM, Phil Mitchell <[email protected] > <javascript:>> wrote: > > > > 1. The docs seem to indicate that dispatchQueue is no longer available > as a property on CBLManager (1.2). I'm on 1.1 and dispatchQueue seems to > solve my problem quite nicely, so I'm hoping this is a documentation bug > (?). > http://developer.couchbase.com/documentation/mobile/current/develop/references/couchbase-lite/couchbase-lite/manager/manager/index.html > > > Those docs are cross-platform and only describe the standard API. They > won’t include platform-specific functionality like access to dispatch > queues. To see what’s available, look at the headers. CBLManager.h includes > a dispatchQueue property. >
Good to know! > > > 2. When I set [CBLManager sharedInstance].dispatchQueue equal to a > serial dispatch queue that I create, I seem to be able to then call CBL > from any queue I want (including syncronously on main queue, and > asynchronously on global queues as well as the serial queue itself). Is > this correct or will this bite me later? > > By “call” do you mean direct method calls, or are you using dispatch_sync > and dispatch_async? > > Direct method calls from other queues/threads will not work correctly. > Dispatching blocks to the CBLManager’s queue will work; that’s exactly what > it’s for. > Sorry, I guess I still don't really understand this. What I'm trying to support is two use cases: 1. Blocking calls from main queue: most classes call into the data store (on the main queue) and wait for a response; 2. Async calls dispatched to background queue: occasionally a class needs to run a longer job on a background thread. But the caller may be quite removed from the store (many intervening classes), so I don't want the call into the store to have to specify which it is. So if I'm understanding you, once I set dispatchQueue, my async calls (explicit dispatch_async()) will work fine, as long as they are dispatched to the same queue. But dispatching to a global queue OR my blocking calls from main queue may be unreliable. Is that correct? And if so, would you advise (internally to the store) wrapping all CBL calls in an explicit dispatch_sync() onto the given dispatchQueue, which would take care of the blocking calls. And the async calls would also work, since they would simply wrap around the sync calls? That would hide everything from callers from the main queue. > > —Jens -- You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/df910268-3ed0-4406-8958-70bed48d83b1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
