News for hackers. Stuff that matters.
Re:Grand Central Dispatch Now Open to All by pohl on Friday September 11, 2009 @12:59PM (#817673)
Drew McCormack has already posted a follow-up that goes into greater detail, including a limited benchmark comparison to OpenMP.

http://www.macresearch.org/cocoa-scientists-xxxi-all-aboard-...

Re:Grand Central Dispatch Now Open to All by pohl on Friday September 11, 2009 @11:33AM (#817511)
It will be interesting to see how the adoption of the syntax for blocks plays out. According to the wikipedia entry for GCD, the proposed C++0x standard has a similar concept, but uses square braces [] instead of the caret ^. The former could be brought down to C, but Objective-C, which is defined as a superset of C, already uses the square braces for object messaging.

Are there any C++ experts who could speak to whether there is any reason that the caret would not work in that language?

(Edit: spelling correction)

Re:Grand Central Dispatch Now Open to All by scott_s on Friday September 11, 2009 @11:50AM (#817545)
The C++0x feature you're referring to is for lamdas (anonymous functions). It might be possible to use another syntax, but it would make parsing (even more of) a nightmare because one can use "&" or "value" inside the square brackets to indicate if values should be pass by-value or by-reference.

In practical terms, I doubt the C++ committee would change the already delayed C++0x standard to accommodate a feature which may (but probably won't) make it into C.

Re:Grand Central Dispatch Now Open to All by pohl on Friday September 11, 2009 @11:59AM (#817563)
Interesting, thank you.

FWIW, it looks like the concept of a block is also an anonymous function, although it looks as if they only allow passing into them by value, not by reference. The developer documentation at Apple indicates that they also support these within C++, and has a small section on how they behave within it. So, at least, they went the extra mile and worked out the C++ parsing issues.

http://developer.apple.com/mac/articles/cocoa/introblocksgcd...

Re:Grand Central Dispatch Now Open to All by pohl on Friday September 11, 2009 @08:12PM (#818389)
I just encountered an interesting and relevant quotation from Chis Lattner:

"To head off the obvious question: this syntax and implementation has nothing to do with C++ lambdas. Blocks are designed to work well with C and Objective-C, and unfortunately C++ lambdas really require a language with templates to be very useful. The syntax of blocks and C++ lambdas are completely different, so we expect to eventually support both in the same compiler."

http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-August/00267...

Re:Grand Central Dispatch Now Open to All by swolchok on Friday September 11, 2009 @01:25PM (#817722)
I believe that Microsoft's Managed C++ uses the caret to indicate a "handle", or managed pointer.
Re:Grand Central Dispatch Now Open to All by rbanffy on Friday September 11, 2009 @05:01PM (#818127)
Microsoft would never support GCD. They will invent something similar completely incompatible that makes it difficult to port programs to any other platform.
Re:Grand Central Dispatch Now Open to All by chime on Friday September 11, 2009 @01:31PM (#817733)
I wish the headline would have been more specific and mention that this relates to Macs. I saw this headline on my phone while waiting for my table at a restaurant. I hurried my way back to work to sign up for it only to realize that it was not Google Voice / Grand Central. I guess I'll have to keep waiting for that.
Re:Grand Central Dispatch Now Open to All by pohl on Friday September 11, 2009 @01:35PM (#817739)
Oh dear...I'm sorry about that. I copied the original headline verbatim, because I once saw someone get flamed for not doing so. This was my first HN submission.
Re:Grand Central Dispatch Now Open to All by edd on Friday September 11, 2009 @03:42PM (#817981)
Modifying headlines is fine as long as you follow the Hacker News Guidlines[1]. Just don't try and mislead people with any changes.

[1]:http://ycombinator.com/newsguidelines.html

Re:Grand Central Dispatch Now Open to All by jsz0 on Friday September 11, 2009 @06:41PM (#818288)
Is there actually a wait for Google Voice? I signed up and got an invite in less than 48 hours about a month ago.
Re:Grand Central Dispatch Now Open to All by yan on Friday September 11, 2009 @12:06PM (#817574)
FYI, they also put up the updated XNU
Re:Grand Central Dispatch Now Open to All by pyre on Friday September 11, 2009 @12:35PM (#817633)
The OS X/Darwin kernel for the unwashed...
Re:Grand Central Dispatch Now Open to All by mr_dbr on Friday September 11, 2009 @12:12PM (#817587)
It would be nice if this was back-ported to Leopard (so you could use GCD without the application being Snow Leopard only), I wonder how difficult this would be..
Re:Grand Central Dispatch Now Open to All by jsz0 on Friday September 11, 2009 @06:43PM (#818290)
More than $29 worth of difficult. That's for sure.
Re:Grand Central Dispatch Now Open to All by antonovka on Friday September 11, 2009 @04:33PM (#818071)
http://code.google.com/p/plblocks/ is probably the place to start.
Re:Grand Central Dispatch Now Open to All by pohl on Friday September 11, 2009 @12:26PM (#817620)
Without special kernel support, you could probably, at the very least, get a thread pool that was local to the process. That might be worth it.
Re:Grand Central Dispatch Now Open to All by GeneralMaximus on Friday September 11, 2009 @11:57PM (#818608)
IIRC, you already have libraries for thread pools on Leopard. Core Foundation would be where I'd start looking.
Re:Grand Central Dispatch Now Open to All by grogers on Friday September 11, 2009 @01:44PM (#817749)
How is this better than any other threadpool library?
Re:Grand Central Dispatch Now Open to All by scott_s on Friday September 11, 2009 @04:22PM (#818052)
System-wide integration and being able to assume it's always present.

You're right in that, as far as I can tell, there are no new ideas in GCD. But it's integrated into the language, compiler, runtime system, kernel, and developers can assume that it is present on any Mac OS 10.6 and greater. That makes a big difference.

Further discussion: http://news.ycombinator.com/item?id=782399

Re:Grand Central Dispatch Now Open to All by wmf on Friday September 11, 2009 @02:08PM (#817784)
I've found very little documentation on this, but apparently the kernel optimizes multiple thread pools to prevent excessive context switches. (Consider an N-core system where multiple processes each create N worker threads of their own.)
Re:Grand Central Dispatch Now Open to All by scott_s on Friday September 11, 2009 @04:25PM (#818058)
Do you mean process migration (rescheduling a process/thread on a different core, which does bad things to caches) instead of context switching (switching between different processes/threads on the same core, which requires saving registers to memory and does bad things to caches)? If so, any decent modern scheduler tries to avoid migrating threads.
Re:Grand Central Dispatch Now Open to All by wmf on Friday September 11, 2009 @04:33PM (#818070)
When I said context switching I meant context switching. Now that you mention it, GCD may also reduce thread migrations. I'm just speculating since we don't know how GCD works.