Custom run loop integration with libdispatch

I am trying to create an application that should manage its own launch cycle. I would like to use libdispatch in this application. However, using libdispatch requires a call to dispatch_main (), which is a locking method. I can not block the main thread.

  • Is there a way to integrate custom startup loops with libdispatch without using dispatch_main () lock?
  • I see links to _dispatch_main_queue_callback_4CF in queue.c from libdispatch, which looks promising. Is there a way to use this method to achieve the same? The documentation for this method is rather scarce.
  • Ideally, I do not need to use NSRunLoop / CFRunLoop.
+3
source share
1 answer

libdispatch does not require a call dispatch_main(), it integrates with the main sample of the main thread through the main send queue, see section dispatch_get_main_queue(3)and COMPATIBILITY.

Executable files that do not invoke dispatch_main()and want to use the main queue must run the main thread's runloop in one of the common modes for blocks in the main send queue for processing; either indirectly through standard raster methods (for example, NSApplicationMain()), or directly through the CFRunLoop or NSRunLoop APIs.

Please do not try to use a symbol _dispatch_main_queue_callback_4CF, this is an internal part of the implementation that may change in the future, and any code that relies on it will be interrupted without warning.

libdispatch CFRunLoops , , API CFRunLoopPerformBlock() runloop.


: Linux, libdispatch, runloops AFAIK.

runloop Linux, , , ( ) _dispatch_main_queue_callback_4CF() _dispatch_queue_wakeup_main() , runloop (, , runloop).

+8

All Articles