• 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: Implementing a "Synchronous Channel" with dispatch
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing a "Synchronous Channel" with dispatch


  • Subject: Re: Implementing a "Synchronous Channel" with dispatch
  • From: Kyle Sluder <email@hidden>
  • Date: Wed, 14 Sep 2011 10:18:16 -0700

On Wed, Sep 14, 2011 at 9:38 AM, Andreas Grosam <email@hidden> wrote:
> A "Synchronous Channel" (or Synchronous Queue) is a well known pattern used in multithreading. Basically, it is used to "hand off" objects from one thread to another, with the requirement that the "producer" waits until a "consumer" took the object.

If you want to block the producer until its object is consumed, why
not use dispatch_sync?

void producer() {
  while (1) {
    dispatch_sync(consumer_queue, ^{
      dispatch_async(consumer_queue, ^{
        // consume the thing
      }
    }
  }
}

--Kyle Sluder
_______________________________________________

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: Implementing a "Synchronous Channel" with dispatch
      • From: Andreas Grosam <email@hidden>
References: 
 >Implementing a "Synchronous Channel" with dispatch (From: Andreas Grosam <email@hidden>)
 >Re: Implementing a "Synchronous Channel" with dispatch (From: Dave Zarzycki <email@hidden>)
 >Re: Implementing a "Synchronous Channel" with dispatch (From: Andreas Grosam <email@hidden>)

  • Prev by Date: UISplitViewController + UIView on UIWindow
  • Next by Date: NSURLRequest timing
  • Previous by thread: Re: Implementing a "Synchronous Channel" with dispatch
  • Next by thread: Re: Implementing a "Synchronous Channel" with dispatch
  • Index(es):
    • Date
    • Thread