|Feb 1, 2013, 03:40 PM||#1|
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.
|Feb 2, 2013, 02:03 PM||#3|
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.
|Feb 3, 2013, 11:19 AM||#4|
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.
|Feb 3, 2013, 12:32 PM||#5|
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)
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|Grand central station||Kashchei||OS X Mavericks (10.9)||1||Nov 16, 2013 02:04 AM|
|Grand central had all colors but spoken for||brinycbri||iPhone||0||Sep 20, 2013 07:29 PM|
|Resolved: Grand Central Dispatch||multinode||Mac Programming||2||Aug 31, 2013 01:25 AM|
|iPad Mini: Report from Apple Store Grand Central (NYC) - 70% scalpers in line||gusnyc||iPad||0||Nov 2, 2012 11:30 AM|
|iPhone 5 - Grand Central Terminal Meetup||slippery||iPhone Launch Meetups||0||Sep 11, 2012 03:23 PM|
All times are GMT -5. The time now is 01:31 PM.