Re: How to throttle rate of NSInputStream?
Re: How to throttle rate of NSInputStream?
- Subject: Re: How to throttle rate of NSInputStream?
- From: "email@hidden" <email@hidden>
- Date: Tue, 27 Mar 2012 22:36:40 +0100
On 27 Mar 2012, at 00:13, Jens Alfke wrote:
>
> This seems to hinge on the way the stream calls my event handler. When I get the NSStreamEventHasBytesAvailable, I only read 8k bytes of data at a time, then return. What seems to happen is that, if that didn’t consume all of the available data, the stream will keep sending me the event in a tight loop without exiting back to the runloop in between.
Jens
You probably already have this sorted but it occurred to me that when you receive NSStreamEventHasBytesAvailable you don't have to read the data there and then. You
can defer the actual reading to some later moment and coalesce the reading operations. This may cause the NSInputStream to buffer up and give the run loop a breather.
Regards
Jonathan Mitchell
Mugginsoft LLP
_______________________________________________
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