Hello Jens, and thanks for the very useful information.

I still don't quite understand how to employ CFWriteStreamSetDispatchQueue. Can 
an NSOperation somehow obtain the dispatch_queue on which it is running?

I know NSOperationQueue has an accessor for its underlying dispatch_queue, but 
actual NSOperations are spawned in arbitrary threads - so I'm not sure about 
their dispatch_queue (if they run on a dispatch_queue at all). 

Supposedly I'd schedule my output stream on the OperationQueue's 
dispatch_queue. What kind of synchronization can I expect? Does this promise 
that stream events won't happen concurrently as my NSOperation's main()?

Also - If I need to reschedule the stream to each operation's dispatch_queue 
(provided they can each have a different one) is it advisable to reschedule a 
stream mid-running? how costly this is? Can I lose events that way?


However - my original hesitation remains - 

On 11 בנוב 2015, at 18:53, Jens Alfke wrote:

> 
>> On Nov 11, 2015, at 3:46 AM, Motti Shneor <su...@bezeqint.net> 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

Motti Shneor, 
CEO,  suMac LTD.
Software Development for the Macintosh

Home/Office Address: 34 Emek-Ha-Ella St. Appt.1 Modiin, ISRAEL, 71723
Home/Office Tel/Fax: +972-8-9267730
Home eMail: motti.shn...@gmail.com Office eMail: su...@bezeqint.net
Mobile phone: +972-54-3136621
---
ceterum censeo microsoftiem delendam esse
---










 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (Macnetworkprog@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to