• 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: When does NSInputStream's -getBuffer:length: actually work?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When does NSInputStream's -getBuffer:length: actually work?


  • Subject: Re: When does NSInputStream's -getBuffer:length: actually work?
  • From: Andreas Grosam <email@hidden>
  • Date: Fri, 27 Jul 2012 10:16:01 +0200

On 25.07.2012, at 19:08, Jens Alfke wrote:

> NSInputStream has a -getBuffer:length: method that lets you get the available data from the stream without copying. This is great for performance, and I've written my client code to take advantage of it if it's supported, but every time I've tested, it isn't supported (i.e. just returns NO) so my code just falls back to calling -read:maxLength: instead.
>
> Does anyone know in what circumstances, or in what types of streams, this method actually works?


I could imagine where this can NOT work:

In cases where the buffer is shared for input and output. Since the two streams could possibly execute on different threads, returning the internal buffer in the input stream's thread while the output stream is still executing will likely result in a race condition of the buffers content.

So, I would guess CFStreamCreateBoundPair and possibly all CFStreamCreatePairWith* won't work.


Andreas


_______________________________________________

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

References: 
 >When does NSInputStream's -getBuffer:length: actually work? (From: Jens Alfke <email@hidden>)

  • Prev by Date: FSEvents eventid (or perhaps event)'s life
  • Next by Date: Re: Debugging -setNeedsDisplayInRect:
  • Previous by thread: Re: When does NSInputStream's -getBuffer:length: actually work?
  • Next by thread: What's the build number of 10.8?
  • Index(es):
    • Date
    • Thread