On Apr 19, 2014, at 11:42 AM, Ragu Vijaykumar <[email protected]> wrote:

> I was wondering how to properly use CBL both in the main thread and 
> background thread to the same database. Should I instantiate a CBLManager 
> both in the main thread ([CBLManager sharedInstance]) and background thread 
> ([[CBLManager sharedInstance] copy]) and then basically treat the two as if 
> they were running in separate programs (each using their own CBLModels, etc.) 
> with no sharing between the two?

Exactly. Basically, those classes are not thread-safe. However, the database 
file itself is thread-safe.

> If I share the docIDs (NSStrings) between the threads, do I just make a 
> CBLDocument with the docID and CBLModel with the CBLDocument in both threads 
> and operate that way?


Yes.

Also, if you listen for change notifications, they will tell you about changes 
made by other threads. So if you write your UI code so that the controllers are 
driven by change modifications and update the views accordingly, then it will 
Just Work.

--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/3A5867E8-B1E6-4233-B7A1-18BD00F0F46B%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to