• 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: Exiting non-POSIX threads?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exiting non-POSIX threads?


  • Subject: Re: Exiting non-POSIX threads?
  • From: Richard Somers <email@hidden>
  • Date: Thu, 01 Aug 2013 08:55:59 -0600

On Jul 29, 2013, at 2:34 AM, Oleg Krupnov <email@hidden> wrote:

> Is there a way to exit a GCD thread?

You can exit a GCD thread with something like this.

- (void)invalidateQueue
{
    _isQueueCanceled = YES;
    dispatch_sync(_queue, ^{});
}

- (void)submitWorkToBeDone
{
    dispatch_async(_queue, ^{
        for ( ... ) {
            if (_isQueueCanceled == YES) {
                break;
            } else {
                // do work
            }
        }
    });
}

When invalidateQueue returns the thread has been canceled.

Richard Somers

_______________________________________________

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


  • Follow-Ups:
    • Re: Exiting non-POSIX threads?
      • From: Kyle Sluder <email@hidden>
    • Re: Exiting non-POSIX threads?
      • From: Sean McBride <email@hidden>
  • Prev by Date: Re: [BUG?] LSUIElement=YES and NSWorkspaceDidTerminateApplicationNotification
  • Next by Date: Re: Exiting non-POSIX threads?
  • Previous by thread: Re: [BUG?] LSUIElement=YES and NSWorkspaceDidTerminateApplicationNotification
  • Next by thread: Re: Exiting non-POSIX threads?
  • Index(es):
    • Date
    • Thread