discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Grand Central Dispatch


From: TMC
Subject: Re: Grand Central Dispatch
Date: Fri, 11 Sep 2009 13:45:41 -0700 (PDT)

Some background:
1. This is a thread pool, but it's system-wide. The kernel knows best (how
to allocate threads), so it is in control.
2. It's lower-level than Cocoa / OpenStep. It is not related to them and it
does not require them. A unix app written for the K Desktop Environment
could be written to use Grand Central Dispatch.
3. It requires Blocks. This means you must use LLVM and C, Obj-C, or C++.
4. It's very easy to use. The following is an example from Ars Technica's
explanation. The `dispatch` lines instruct GCD to create a task (containing
another task) that will be assigned to a thread.

  - (IBAction)analyzeDocument:(NSButton *)sender 
  { 
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
      NSDictionary *stats = [myDoc analyze]; 
      dispatch_async(dispatch_get_main_queue(), ^{
        [myModel setDict:stats]; 
        [myStatsView setNeedsDisplay:YES]; 
        [stats release];
      });
    });
  }

--Tycho Martin Clendenny
-- 
View this message in context: 
http://www.nabble.com/Grand-Central-Dispatch-tp25401545p25408068.html
Sent from the GNUstep - General mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]