Linked by Thom Holwerda on Tue 13th Oct 2009 18:24 UTC, submitted by Lazarus
FreeBSD Not too long ago, Apple open sourced its Grand Central Dispatch library, which aids in developing multithreaded code. It was suggested that it could be ported to other platforms, and the FreeBSD team has done exactly that. They have also done a lot of work related to getting GCD to work in a POSIX environment.
Thread beginning with comment 389109
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[5]: Neato
by Lunix on Wed 14th Oct 2009 05:12 UTC in reply to "RE[4]: Neato"
Member since:

Theres plenty of info here:

Aside from the closure structure, there's a second structure for __block variables (which are shared and mutable). There may also code generated for calling c++ copy constructors/destructors and Objective C retain/release-ing.

Blocks are never magically moved from the stack to the heap. There are two runtime function calls -- Block_copy(block) and Block_destroy(block) -- for managing block lifetime. (Objective C people can use [block copy] / [block release]).

If the block is stored on the stack, Block_copy will copy it to the heap (and return a pointer to the new heap block). Otherwise, it just increments a reference counter.

If you pass your block to a function that keeps it around for later, then it will get copied to the heap (if necessary). C is not doing anything behind your back, though.

Edited 2009-10-14 05:14 UTC

Reply Parent Score: 3

RE[6]: Neato
by Mark Williamson on Wed 14th Oct 2009 13:21 in reply to "RE[5]: Neato"
Mark Williamson Member since:

Thanks for the info! I had researched it a bit when I first heard about it but didn't find any solid references. If nothing happens automagically then it sounds a) great and b) inoffensive. There's so much code that would benefit from a form of closures. I'll take a llok at the docs you linked.

Reply Parent Score: 2