Enqueues a block object on a given runloop to be executed as the runloop cycles in specified modes.


void CFRunLoopPerformBlock(CFRunLoopRef rl, CFTypeRef mode, void (^block)(void));



A run loop.


A CFString that identifies a runloop mode, or a CFArray of CFStrings that each identify a runloop mode.


The block object to execute.

The block is copied by the function before the function returns.


When the runloop runs in the specified mode, the block object is executed. You can use this function as a means to offload work to another thread similar to Cocoa’s performSelector:onThread:withObject:waitUntilDone: and related methods. You can also use it as an alternative to mechanisms such as putting a CFRunLoopTimer in the other thread's run loop, or using CFMessagePort to pass information between threads.

This method enqueues the block only and does not automatically wake up the specified run loop. Therefore, execution of the block occurs the next time the run loop wakes up to handle another input source. If you want the work performed right away, you must explicitly wake up that thread using the CFRunLoopWakeUp function.