Re: Cancelling CFNetwork operations from another thread?
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