Author Topic: Snow Leopard: GCD  (Read 2806 times)

0 Members and 1 Guest are viewing this topic.

Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
Snow Leopard: GCD
« on: September 02, 2009, 01:30:18 am »
Since there's no Hardware/Software review board any more (and since the post I wanted to reply to seems to have vanished?), I'm posting this here.

This is a page of a long and technical article about SL, and it contains examples of exactly how simple it is to use GCD. When you get to the part that references blocks, follow the link and read about them (they're discussed on page 10); otherwise, the rest of the page won't make much sense.

http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/13

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Snow Leopard: GCD
« Reply #1 on: September 02, 2009, 02:00:36 am »
Interesting.  C# allows a similar pattern with threading; it's insanely easy, and like the Objective-C examples they provided, C# code can capture the surrounding context:
Code: [Select]
void button_Click(object sender, EventArgs e)
{
    new Thread(delegate {
       var result = doSomeWork();
       BeginInvoke(delegate {
           RefreshUI(result);
       });
    }).Start();
}
That's not how I'd write it per se, but it's similar in nature to the Obj-C example the article provided.

It's good that OS X is helping developers out in this way.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
Re: Snow Leopard: GCD
« Reply #2 on: September 02, 2009, 02:39:38 am »
Somewhat off-topic, but...

Page 21 discusses core location in SL. Apparently, the guy that wrote the article lives in the same town as I do! At first I thought the image was stalking me...
« Last Edit: September 02, 2009, 01:47:21 pm by Camel »

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!

Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
Re: Snow Leopard: GCD
« Reply #3 on: September 02, 2009, 02:00:34 pm »
...C# code can capture the surrounding context:
Pretty much every modern language that isn't based on C is either fully dynamic, or at least has that feature.

Frankly, now that it's out there, I'm surprised no one did this to C when the idea was new 15 years ago. I didn't really step back and appreciate how useful this feature is until I read this article. I wrote approximately 400 lines of code in one particular Java class this morning, and I used 10 cross-context references without even a thought to how much work the compiler just did for me.

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!