• 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 10:48:27 -0600

On Jan 17, 2013, at 10:22 AM, Kyle Sluder <email@hidden> wrote:

> On Jan 17, 2013, at 2:09 AM, Charles Srstka <email@hidden> 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 (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: 
 >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>)
 >Re: Thread synchronization via queue (From: Charles Srstka <email@hidden>)
 >Re: Thread synchronization via queue (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Thread synchronization via queue
  • Next by Date: NSTextfield focus in contextual menu
  • Previous by thread: Re: Thread synchronization via queue
  • Next by thread: Re: Thread synchronization via queue
  • Index(es):
    • Date
    • Thread