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 6545373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:34:42+00:00 2026-05-25T11:34:42+00:00

I currently have a shell script that process many images one after the other,

  • 0

I currently have a shell script that process many images one after the other, with the help of GraphicsMagick. It works fine, all calculations are correct, everything works. (that’s not a “simple” script, it involves reading dimensions from a JSON file, converting a bunch of images with respect to many constraints).

As we’re working with dual-core or quad-core computer, I’d like to parallelize it. And as I’m an iPhone developer liking to introduce myself to Mac development, I’d like to create it with XCode and Objective-C using the “command-line tool” template.

So far so good, but now I’m face with the design of the “task dispatcher” object. I’m fairly lost between running NSTasks in a run loop, in separate threads, using blocks, with or without GCD, with or without ARC.

How would one achieve this? I was thinking of using simple threads to spawn NSTasks, having them report when they’re done, and notify my dispatcher’s delegate so that it can upgrade its progress bar. But I’d really like to get in touch with Grand Central Dispatch. Does anyone have any thoughts, ideas, advice about what to do and what not?

Edit: I’m reading Apple’s docs, and have found the NSOperationQueue class. Could it be that this is precisely what I’m needing here?

  • 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-05-25T11:34:42+00:00Added an answer on May 25, 2026 at 11:34 am

    yes – NSOperation/NSOperationQueue are good for this task.

    i’d start with something like this:

    @protocol MONTaskRequestDelegate
    
    - (void)taskRequestDidComplete:(MONTaskRequest *)taskRequest;
    
    @end
    
    @interface MONTaskRequest : NSOperation
    {
    @private
        NSTask * task;
        NSObject<MONTaskRequestDelegate>* delegate; /* strong reference. cleared on cancellation and completion, */
    }
    
    - (id)initWithTask:(NSTask *)task delegate:(NSObject<MONTaskRequestDelegate>*)delegate;
    
    // interface to access the data from the task you are interested in, whether the task completed, etc.
    
    @end
    
    @implementation MONTaskRequest
    
    // ...
    
    - (void)performDelegateCallback
    {
        [self.delegate taskRequestDidComplete:self];
        self.delegate = nil;
    }
    
    - (void)main
    {
        NSAutoreleasePool * pool = [NSAutoreleasePool new];
    
        [self runTheTask];
        // grab what is needed and handle errors
        [self performDelegateCallback];
    
        [pool release];
    }
    
    - (void)cancel
    {
        [super cancel];
        [self stopTaskIfPossible];
        [self performDelegateCallback];
    }
    
    @end
    

    then you can use NSOperationQueue to limit the number of active tasks to a reasonable number.

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

Sidebar

Related Questions

Currently I have a perl script that runs forever on my server, checking a
I have a script, that I need to run after committing to a project
I currently have a daily process that loads a large amount of data from
I have a shell script that pulls the number of online players, but I
I have a script that runs from a newly created shell. OS is Red
I have a shell script which copies a few files to the current directory,
I currently have an MS Access application that connects to a PostgreSQL database via
I have this shell script #!/bin/sh ############################################################# # Example startup script for the SecureTrading
I have a KornShell (ksh) script that logins into SQL*Plus and executing a script.
I'm currently working on a small script that needs to use gtk.StatusIcon() . For

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.