• 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: Killing a stuck NSThread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Killing a stuck NSThread


  • Subject: Re: Killing a stuck NSThread
  • From: Douglas Davidson <email@hidden>
  • Date: Wed, 26 Apr 2006 14:24:33 -0700


On Apr 26, 2006, at 2:19 PM, Paul Forgey wrote:

Your Cocoa app is event driven. Take advantage of it. Use an NSSocketPort to do what you want, or if you must use a separate thread to do I/O at the posix level, use non-blocking sockets in a select loop. From the select loop, you can poll for a timeout condition after waiting for a maximum time. But using an NSSocketPort is so much easier and you won't waste a thread just to wait for network conditions.


CFSocket is the low-level abstraction for using a socket as a run loop source; NSSocketPort is something different (an NSPort subclass implemented using CFSocket). Higher-level approaches include CFStream, NSURLConnection, etc.


If you do use your own separate networking thread and block in select, you can create an extra local socket (say, via socketpair) and add it to your select set; then your other threads can use that socket to tell the networking thread to wake up and respond, e.g. to a cancellation state.

Douglas Davidson

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Killing a stuck NSThread
      • From: Paul Forgey <email@hidden>
References: 
 >Killing a stuck NSThread (From: Dustin Wenz <email@hidden>)
 >Re: Killing a stuck NSThread (From: Axel Andersson <email@hidden>)
 >Re: Killing a stuck NSThread (From: Ivan Kourtev <email@hidden>)
 >Re: Killing a stuck NSThread (From: Paul Forgey <email@hidden>)

  • Prev by Date: Re: Killing a stuck NSThread
  • Next by Date: Bindings in sheet window not working (was: Tables showing different kinds of core data entities)
  • Previous by thread: Re: Killing a stuck NSThread
  • Next by thread: Re: Killing a stuck NSThread
  • Index(es):
    • Date
    • Thread