• 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: Cancelling CFNetwork operations from another thread?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cancelling CFNetwork operations from another thread?


  • Subject: Re: Cancelling CFNetwork operations from another thread?
  • From: Becky Willrich <email@hidden>
  • Date: Wed, 9 Nov 2005 10:23:59 -0800

So, this makes me wonder whether it would be OK to call
CFReadStreamClose() or CFWriteStreamClose() from another thread in order
to abort a "stuck" CFReadStreamRead() or CFWriteStreamWrite() call.
Intuition tells me that this is a bad idea, but it can't hurt to ask. Is
it, in fact, possible to do this?

Don't do that; it's a bad idea. :) Individual streams are not thread-safe, and it's expected that if you need more than the most basic functionality from a stream, you will use the event-based APIs. Starting from your code base, you have two choices - switch to the polling APIs and build in some idle time in your loop (this will definitely hurt performance), or switch to the event-based APIs, and simulate the blocking behavior by running the run loop in a private mode. I'd highly recommend the event-based approach; it will probably improve your performance, leave you well-positioned to use any other CFNetwork features you want, and if you ever decide to change your threading policy, it'll be much easier.


REW

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


References: 
 >Cancelling CFNetwork operations from another thread? (From: Rich Siegel <email@hidden>)

  • Prev by Date: Re: mount() from Cocoa App
  • Next by Date: OpenTransport Timeouts?
  • Previous by thread: Cancelling CFNetwork operations from another thread?
  • Next by thread: Re: AirPort 4.2, firmware 5.6, firmware 6.2 : serious bug!
  • Index(es):
    • Date
    • Thread