... and more importantly I do not believe your code makes correct use of 
dispatch_group_async. Your first call adds a producer block to the global 
concurrent queue, which may start executing immediately. At some time soon 
afterwards you add a consumer block to the global concurrent queue, which again 
may start executing immediately - while the producer block is still in the 
process of "producing". As far as I can see the code appears to have a number 
of major issues:

1. Theoretically your producer block may not have produced anything by the time 
your consumer block executes

2. What happens if your consumer block has processed all the currently-added 
blocks before the producer block has added the eof marker?

3. You have only one single consumer block, which means you will only have a 
single consumer "thread" running under Grand Central Dispatch, which rather 
defeats the purpose of using it at all! I think you may not have fully 
understood how GCD is intended to be used...

4. Are you sure that your mysterious and rather complicated-seeming 
CFDataConstBuffers class is sufficiently threadsafe for your producer to be 
adding to it at the same time as your consumer block is iterating through it? I 
am 99% sure that the "explicit" consumer code you wrote in 
ConcurrentProduceConsume is not threadsafe.

Jonny._______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to