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
Post a Comment