• 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: Thread synchronization via queue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thread synchronization via queue


  • Subject: Re: Thread synchronization via queue
  • From: Charles Srstka <email@hidden>
  • Date: Thu, 17 Jan 2013 04:09:28 -0600

On Jan 17, 2013, at 4:01 AM, Rick Mann <email@hidden> wrote:

> On Jan 17, 2013, at 1:56 , Charles Srstka <email@hidden> wrote:
>
>> On Jan 17, 2013, at 3:40 AM, Rick Mann <email@hidden> wrote:
>>
>>> I've got a situation where I have a complicated process that periodically pulls some bytes out of an NSMutableData. Eventually, it gets to the end of the NSMutableData. At that point, I need the process to block while it waits for a separate process (thread) to give it more data. What I need is a semaphored queue for a producer-consumer type of relationship.
>>>
>>> I don't think there's any way to pull this off using GCD, is there? I can't change the complex process to work in discrete chunks. It needs to chug through the data until it reaches a stopping point, and that might require several waits on more data.
>>
>> Could NSInputStream and NSOutputStream possibly provide what you need?
>
> Hmm, good idea, but it looks like they don't provide blocking reads, which is basically what I need. They're callback-based.

You could start a run loop in a dispatch queue, schedule the NSInputStream on that runloop, and then have the delegate methods block/unblock your reading thread via a lock/semaphore/etc.

Charles

_______________________________________________

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: Thread synchronization via queue
      • From: Kyle Sluder <email@hidden>
References: 
 >Thread synchronization via queue (From: Rick Mann <email@hidden>)
 >Re: Thread synchronization via queue (From: Charles Srstka <email@hidden>)
 >Re: Thread synchronization via queue (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Thread synchronization via queue
  • Next by Date: Re: Using a document bundle file type with core data
  • Previous by thread: Re: Thread synchronization via queue
  • Next by thread: Re: Thread synchronization via queue
  • Index(es):
    • Date
    • Thread