I used a template like this very successfully in our C ++ classes that use send queues for synchronization:
class Foo { public: void doSomething() { dispatch_sync(fQueue, ^{ doSomething_sync(); }); } private: void doSomething_sync() { ... } private: dispatch_queue_t fQueue; };
The general convention here is that for any given _sync method in a class, you only call other _sync methods, and not their public counterpart, not _sync .
source share