• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: GCD question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GCD question


  • Subject: Re: GCD question
  • From: Fritz Anderson <email@hidden>
  • Date: Thu, 19 Jul 2012 10:41:44 -0500

On 19 Jul 2012, at 1:47 AM, Rick C. wrote:

> If I use this to initiate a background "thread":
>
>
> dispatch_async(dispatch_get_global_queue(0, 0), ^{
>
> // do some stuff
>
> [self runMyFunction];
>
> [self runAnotherFunction];
>
> // do some more stuff
>
> });
>
>
> My question is with my sample calling runMyFunction or runAnotherFunction are they blocking? Meaning will they block the background "thread" until they are complete and then it will continue? Or must I put them into another kind of block so that they finish FIFO?  Thanks just looking for a confirmation as I'm moving to GCD from threads...

Grand Central Dispatch and blocks are orthogonal; GCD uses blocks as its unit of work, but does nothing special to them internally. A block is an anonymous (Objective-) C function. It executes from top to bottom, and if it calls a function/method in the middle, the execution path goes into the function, and when the function returns, execution proceeds in the block from there — just like any other function. For that reason, you don't have to serialize -runMyFunction and -runAnotherFunction; they get run one after the other as in any other code.

	— F

--
Fritz Anderson -- Xcode 4 Unleashed: Now in stores! -- <http://x4u.manoverboard.org/>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: GCD question
      • From: "Rick C." <email@hidden>
References: 
 >GCD question (From: "Rick C." <email@hidden>)

  • Prev by Date: Sharing a file between Mac and iOS
  • Next by Date: Re: NSSplitView question - how to implement my own "adjustViews" style method
  • Previous by thread: GCD question
  • Next by thread: Re: GCD question
  • Index(es):
    • Date
    • Thread