> On 11 Jul 2016, at 16:00, Alastair Houghton <[email protected]>
> wrote:
>
> On 11 Jul 2016, at 06:35, Gerriet M. Denkmann <[email protected]> wrote:
>>
>> I have a subclass of NSThread (called MyThread), which runs a RunLoop in
>> main.
>> When it gets cancelled, it leaves the RunLoop and main will exit.
>
> One further thought on this: it looks like you might be duplicating the
> functionality of NSOperationQueue and/or GCD, in which case you might
> consider using those instead?
Yes. I liked the idea of GCD better than NSLocks.
I created a serial queue for MyThread called serialQueue.
Then I overrode cancel in MyThread:
- (void)cancel
{
dispatch_async( self.serialQueue, ^void{ [ super cancel ] } );
}
And added to MyThread:
- (void)performSelector: (SEL)aSelector withObject: object;
{
dispatch_async( self.serialQueue, ^void
{
if ( self.isCancelled ) return;
[ self performSelector: aSelector
onThread: self
withObject: object
waitUntilDone: NO
];
}
);
}
I think this solves my problem.
Thanks a lot for your help!
Kind regards,
Gerriet.
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]