From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: text/plain; charset=windows-1252; format=flowed; delsp=yes Mime-Version: 1.0 (Apple Message framework v1075.2) From: Daniel Lyons In-Reply-To: <98e535534bd51792a5db3b7af4034fc6@quanstro.net> Date: Thu, 3 Sep 2009 16:10:20 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <626D9216-7A6B-447E-A490-E91D8863D0C8@storytotell.org> References: <98e535534bd51792a5db3b7af4034fc6@quanstro.net> To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Subject: Re: [9fans] "Blocks" in C Topicbox-Message-UUID: 6346a438-ead5-11e9-9d60-3106f5b1d025 On Sep 3, 2009, at 10:02 AM, erik quanstrom wrote: > in c, i don't see why such a bolt-on would be useful in > c, especially since your concurrent fifo would be limited > to one shared-memory node unless you're going to add a runtime > compiler. It's primarily an aesthetic benefit. =46rom = http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/13 - (IBAction)analyzeDocument:(NSButton *)sender { NSDictionary *stats =3D [myDoc analyze]; [myModel setDict:stats]; [myStatsView setNeedsDisplay:YES]; [stats release]; } becomes - (IBAction)analyzeDocument:(NSButton *)sender { dispatch_async(dispatch_get_global_queue(0, 0), ^{ NSDictionary *stats =3D [myDoc analyze]; dispatch_async(dispatch_get_main_queue(), ^{ [myModel setDict:stats]; [myStatsView setNeedsDisplay:YES]; [stats release]; }); }); } Two more lines of code, and it will execute that block in another =20 thread without having to do much thinking about it. =97 Daniel Lyons