Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7844907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:03:00+00:00 2026-06-02T17:03:00+00:00

I am trying to build an application that must manage its own run loop.

  • 0

I am trying to build an application that must manage its own run loop. I would like to use libdispatch in this application. However, using libdispatch requires calling dispatch_main() which is a blocking method. I cannot block on the main thread.

  1. Is there a way to integrate custom run loops with libdispatch without using the blocking dispatch_main()?
  2. I see references to _dispatch_main_queue_callback_4CF in queue.c of libdispatch which looks promising. Is there a way to use this method to achieve the same? Documentation on this method is quite sparse.
  3. Ideally, I should not need to use an NSRunLoop/CFRunLoop.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:03:03+00:00Added an answer on June 2, 2026 at 5:03 pm

    libdispatch does not require calling dispatch_main(), it integrates with the main thread’s runloop through the dispatch main queue, see dispatch_get_main_queue(3) and the COMPATIBILITY section therein.

    Executables that do not call dispatch_main() and want to use the main queue must run the main thread runloop in one of the common modes for blocks on the dispatch main queue to be processed; either indirectly via standard framework methods (e.g. NSApplicationMain()) or directly via CFRunLoop or NSRunLoop APIs.

    Please do not attempt to use the _dispatch_main_queue_callback_4CF symbol, it is an implementation detail internal to the library that is very likely to change in the future and any code that relies on it will break without warning.

    Integration of libdispatch with custom non-main-thread CFRunLoops can be achieved in a number of ways, such as via the CFRunLoopPerformBlock() API or custom runloop sources.


    Update: on Linux, you’ll have to modify the libdispatch sources, there is no existing support for interoperating with custom runloops AFAIK.

    The simplest way to integrate the main queue with an existing runloop on Linux is probably indeed going to be to call the (preferably renamed) _dispatch_main_queue_callback_4CF() function each time through the event loop, and replace
    _dispatch_queue_wakeup_main() with whatever method is appropriate to wake your runloop (e.g. write to a pipe the runloop is waiting on).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build an Eclipse application that would work with a linux/motif
I'm trying to build a simple GAE application that would read a textbox, pass
I'm trying to build an application that builds a resource file into a jar,
I'm trying to build a application that has different kinds of users, I'm using
i'm trying to build an application that every given time, will connect to a
I'm currently trying to build an application that inherently needs good time synchronization across
I'm trying to build an iPhone application that has two subviews in the main
I have an application that I'm trying to build with at least a nominally
I am trying to build an application for iphone with using storyboard that starting
I'm trying to build an application from source in windows that requires some Unix

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.