Re: Integrating NSOutputStream and NSOperation
Re: Integrating NSOutputStream and NSOperation
- Subject: Re: Integrating NSOutputStream and NSOperation
- From: Jens Alfke <email@hidden>
- Date: Wed, 11 Nov 2015 08:53:50 -0800
On Nov 11, 2015, at 3:46 AM, Motti Shneor < email@hidden> wrote:
If I (upon starting my operation) schedule the outputStream on the current operation’s runloop like thus:
[self.outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
That won’t work because dispatch queues (other than main) and NSOperationQueues don’t have runloops. (If you call +currentRunLoop you do create a new runloop for whatever thread the queue is using, but that runloop won’t do anything because there’s no outer loop on that thread servicing it.) If I can change the outputStream’s scheduling to use the same of my currently running operation - that should solve my synchronizing problem. My operation can bail safely, and be re-called on its own thread, without concurrency.
You can use CFWriteStreamSetDispatchQueue to schedule the stream on a queue instead of a runloop.
—Jens |
_______________________________________________
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