Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Feb 1, 2013, 02:40 PM   #1
macrumors 6502
Join Date: Sep 2006
Books on Grand Central Dispatch

Are there any good books on using Grand Central Dispatch? I've found:
Concurrent Programming in Mac OS X and iOS

but I wanted to know what books people recommend. I'm not a programming expert and I'm looking to learn how to properly implement concurrency. For example, I want to do any importing or parsing on a separate thread, but be able to stop the parsing process if the user selects a different file. That way there isn't a big lag between selections.

I've gone through the Concurrency Programming Guide and read some posts on cimgf.com, but I still feel a little lost and could use the step-by-step explanations found in a book dedicated to the topic.
klaxamazoo is offline   0 Reply With Quote
Old Feb 2, 2013, 10:23 AM   #2
macrumors regular
Join Date: Aug 2011
Location: Stockholm Sweden
Hmm. Looks like a quite convoluted way of doing things. Might be good in very special circumstances.

Look at "normal" concurrent programming instead, here is one example.

// gunnar
ghellquist is offline   0 Reply With Quote
Old Feb 2, 2013, 01:03 PM   #3
macrumors 6502a
Join Date: Jan 2010
Location: San Diego, CA USA
GCD is a tool to help with multi-threading. It can be a useful way to break a problem down into steps. But it isn't the only way to handling threading. When you have several tools (like GCD) available, it's a good idea to use tools that make sense. Having written some code that uses GCD, I would say that file processing is probably not something GCD is best used for. Instead, I would create a separate thread and just let that separate thread read the file. No GCD stuff is needed.

If you're making a GUI app, then the main thread would be handling the UI. If the user presses the "stop" button, then the main thread can set a "stop now" flag. The file processing thread should check that flag (for example, every time it reads a line in the file) and stop reading if the flag is set.

You will need to perform synchronization of data between the file-reading thread and whatever logic is consuming the data being read in the file.
mfram is offline   0 Reply With Quote
Old Feb 3, 2013, 10:19 AM   #4
Thread Starter
macrumors 6502
Join Date: Sep 2006
Thanks for the recommendations. I guess that is why I'm looking for a book that details how to properly implement multithreading/GCD so that I don't tie up the main thread anymore. I would like to know when to use it, how to use it properly, what are the best practices, how to deal Core Data and Views, etc.

I'm looking for a book because they usually have examples that start with something simple and slowly build upon it while discussing why things are done this way. Once I have a basic understanding behind the concepts and how to implement them, it is much easier to go through Apples documentation or example code.
klaxamazoo is offline   0 Reply With Quote
Old Feb 3, 2013, 11:32 AM   #5
macrumors 603
Join Date: Aug 2009
It's difficult to suggest a book without knowing where you are in your understanding of threading, and what experience you have working with it, if any.

It would help if you listed what references, tutorials, examples, etc. you've already gone through. Also, if you've had difficulties with some reference or tutorial, exactly where was the difficulty.

Examples of relevant Apple docs:
Cocoa Core Competencies

You seem to be using the terms threading and GCD almost interchangeably, when they are anything but. Because parsing deals with streams of data, and you want its action to be interruptible, it makes more sense to use a thread, in the way mfram pointed out (a "stop now" flag). GCD blocks are more oriented towards performing a single well-encapsulated action to completion. A typical parser would have to be "turned inside-out" in order become a set of dispatchable yet sequence-interruptible blocks (effectively a finite-state machine)
chown33 is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Grand central station Kashchei OS X Mavericks (10.9) 1 Nov 16, 2013 01:04 AM
Grand central had all colors but spoken for brinycbri iPhone 0 Sep 20, 2013 06:29 PM
Resolved: Grand Central Dispatch multinode Mac Programming 2 Aug 31, 2013 12:25 AM
iPad Mini: Report from Apple Store Grand Central (NYC) - 70% scalpers in line gusnyc iPad 0 Nov 2, 2012 10:30 AM
iPhone 5 - Grand Central Terminal Meetup slippery iPhone Launch Meetups 0 Sep 11, 2012 02:23 PM

Forum Jump

All times are GMT -5. The time now is 08:06 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC