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

  • SEARCH
  • Home
  • 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 8688621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:24:58+00:00 2026-06-12T23:24:58+00:00

I am writing an application with a plugin system. Plugins must work on the

  • 0

I am writing an application with a plugin system. Plugins must work on the main thread (this is not part of the question, I’m not looking for a bunch of answers that say I should remove this requirement).

Plugins get initialised asynchronously so the UI doesn’t hang for a few seconds on launch, but other code immediately starts to interact with the plugins after launch. This obviously needs to be delayed until the plugins have finished loading.

Here is what I’ve got so far…

// Create operation queue
dispatch_queue_t queue = dispatch_queue_create(...);
dispatch_suspend(queue);

// Load the plugins
dispatch_group_t group = dispatch_group_create();
for each plugin {
    dispatch_group_async(group, dispatch_get_main_queue(), ^{
        load...
    });
}
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
    dispatch_resume(queue);
});

// Add operations that interact with the plugins
dispatch_async(queue, ^{
    dispatch_async(dispatch_get_main_queue(), ^{
        operation...
    });
});

This will mean that any operations submitted won’t start until the plugins have finished loading, however, any new operations will go through two queues before actually being processed. Is this a large overhead? Would it be worth queueing to begin with, and then swapping out method implementations when ready for one that doesn’t bother queueing? This would be more tricky to do and I don’t know if it would be worth it.

Finally, is there a better design pattern for this type of problem? Perhaps I should be using NSOperations and NSOperationQueues with dependencies? Or would they have a higher overhead than basic GCD operations?

  • 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-12T23:24:59+00:00Added an answer on June 12, 2026 at 11:24 pm

    The “double overhead” is actually really low, but there is a slightly better design pattern you can use for this that is also more intuitive. Create your operation queue and then use dispatch_set_target_queue(queue, dispatch_get_main_queue()) to make it, in essence, a sub-queue of the main queue. This will ensure it executes on the main thread while not requiring you to do the cross-submission – you’ll just submit the plug-in operation(s) directly to the operation queue.

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

Sidebar

Related Questions

I'm possibly writing a plugin system for a Cocoa application (Mac, not iPhone). A
I am writing an application that supports plugins. Plugin creator is responsible for providing
I'm writing a plugin system to run client-provided untrusted code in my server application
I'm writing a plugin for a closed source application called Max/MSP . To work
I'm writing an application that includes a plugin system in a different assembly. The
I am currently writing a ruby plugin for a 3d drawing application(written in c
I am thinking about writing a plugin for email application. It can be put
I am writing application in Linux using C, pthreads and sockets. This will be
I am writing a plugin for a application, occasionally a SIGSEGV would be throw
I'm writing a DLL plugin for a windows application, after adding the following includes:

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.