On Jan 17, 2013, at 10:22 AM, Kyle Sluder <k...@ksluder.com> wrote:

> On Jan 17, 2013, at 2:09 AM, Charles Srstka <cocoa...@charlessoft.com> wrote:
> 
>> 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.
> 
> Do not start a runloop in a block submitted to a dispatch queue. You do not 
> own the thread that your block is executing on, therefore you should not 
> mutate thread state. For all you know, if you dispatch_async from a 
> background thread, your block will execute on the main thread.

Ah, good point. I shouldn't have written that post at 4 AM.

That's not really the only problem with that post; in actuality, there's no 
reason that the NSInputStream would have to be on another thread at all. You 
could just schedule it on the main run loop; since all it would be doing would 
be sending signals to the worker thread anyway, it's unlikely that it would 
take much time from the thread it's running in.

Charles

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to