• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threads


  • Subject: Re: Threads
  • From: email@hidden
  • Date: Mon, 11 Jul 2016 18:57:59 +0900

Just be sure to write tests that prove it does what you want it to do. ;)

Sent from my iPhone

> On Jul 11, 2016, at 6:18 PM, Gerriet M. Denkmann <email@hidden> wrote:
>
>
>> On 11 Jul 2016, at 16:00, Alastair Houghton <email@hidden> wrote:
>>
>> On 11 Jul 2016, at 06:35, Gerriet M. Denkmann <email@hidden> 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@hidden)

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:

This email sent to email@hidden


References: 
 >Threads (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: Threads (From: Alastair Houghton <email@hidden>)
 >Re: Threads (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: Threads
  • Next by Date: Hello. Is there a way to stop Apple CrashReporter from collecting crashes of my process?
  • Previous by thread: Re: Threads
  • Next by thread: Hello. Is there a way to stop Apple CrashReporter from collecting crashes of my process?
  • Index(es):
    • Date
    • Thread