couchbaselabs / CouchCocoa

Objective-C API for CouchDB on iOS and Mac OS
http://couchbaselabs.github.com/CouchCocoa/docs/
218 stars 66 forks source link

[performSelector: withObject: afterDelay: ] is not guarantee to be performed #33

Closed robin closed 12 years ago

robin commented 12 years ago

[performSelector: withObject: afterDelay: ] may not be performed if it is called in a thread without proper run loop. This affects several places in CouchCocoa where this method is used.

For example, if a CouchPersistentReplication is created in a dispatch_async block not queuing in main thread, the replicator won't start automatically because the autosave use [performSelector: withObject: afterDelay: ] to perform save.

snej commented 12 years ago

The answer is "don't do that". CouchCocoa is not thread-safe and should only be called from a single thread, one which has a runloop.