News:

How did you even find this place?

Main Menu

Snow Leopard: GCD

Started by Camel, September 02, 2009, 01:30:18 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Camel

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!

MyndFyre

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:

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.
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.

Camel

#2
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...

<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!

Camel

Quote from: MyndFyre on September 02, 2009, 02:00:36 AM
...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!