Re: Integrating NSOutputStream and NSOperation
Re: Integrating NSOutputStream and NSOperation
- Subject: Re: Integrating NSOutputStream and NSOperation
- From: "Quinn \"The Eskimo!\"" <email@hidden>
- Date: Thu, 12 Nov 2015 08:40:23 +0000
On 11 Nov 2015, at 11:46, Motti Shneor <email@hidden> wrote:
> I have an NSOutputStream created and scheduled on some pre-created NSTrhead’s NSRunloop (a.k.a mySocketThread).
>
> …
>
> I have special difficulty with operation cancellation. I can (of course) cancel scheduled messages that didn’t start, but I cannot (server protocol) send half-messages to my server - hence I can only abort a cancelled operation if stream error or end occurred (again - I can only know this via stream events).
In this situation I'd introduce a lay of abstraction between your stream and your operations. That is, have all the code that's managing your stream run on the run loop, where it's serialised and life is sane. That code would be responsible for all the framing and unframing of messages, presenting an abstraction that's entirely message based. Then have your NSOperation code talk to that via some sort of inter-thread messaging.
Share and Enjoy
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
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