objective c - @synchronized or serial dispatch queues -


this question has answer here:

is there performance gain when using serial dispatch queue (assuming high or default priority) on @synchronized blocks serialize access resource. gain, mean difference in overhead due synchronization mechanism itself.

certainly. there's differences in semantics though. @synchronized block uses recursive, exception-safe mutex in side-table. of properties lead additional overhead. dispatch_queue_t extremely light weight (especially when using dispatch_*_f avoid block_copy()), non-recursive, doesn't handle exceptions, , doesn't guarantee particular thread.

personally, think recursive locks bad idea, , exceptions shouldn't caught in cocoa apps, @synchronized has little appeal.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -