• 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
NSOperation thread priority ignored?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSOperation thread priority ignored?


  • Subject: NSOperation thread priority ignored?
  • From: Rick Mann <email@hidden>
  • Date: Wed, 25 Apr 2012 20:23:38 -0700

I'm trying to create an NSBlockOperation and set its thread priority. But when the block executes, the thread priority of the running thread is 0.5. The code is below. Here's what it logs:

2012-04-25 20:22:47.096 app[13283:494b] UPDATING MAG MODEL. Thread <NSThread: 0x1a1ec0>{name = (null), num = 33} priority: 0.500000. Main: 0

The thread priority should be 0.1. Am I overlooking something?

- (void)
updateMagModel: (NSTimer*) inTimer
{
    NSBlockOperation* op = [NSBlockOperation blockOperationWithBlock:
    ^{
        //  TODO: update the model.

        NSThread* t = [NSThread currentThread];
        NSLog(@"UPDATING MAG MODEL. Thread %@ priority: %f. Main: %d", t, t.threadPriority, [NSThread mainThread] == t);
    }];

    op.threadPriority = 0.1;

    op.completionBlock =
    ^{
        //  Schedule the timer to fire the next operation, but
        //  make sure to do it on the main queue, so that the
        //  setup code runs on the main queue…

        [NSOperationQueue addOperationOnMainQueueWithBlock:
        ^{
            [NSTimer scheduledTimerWithTimeInterval: kMagModelUpdateInterval
                        target: self
                        selector: @selector(updateMagModel:)
                        userInfo: nil
                        repeats: false];
        }];
    };

    [mMagModelUpdateQueue addOperation: op];
}

Thanks!

--
Rick


_______________________________________________

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


  • Prev by Date: Re: Executing a very low-priority operation in iOS
  • Next by Date: Why can't I change the font used by an NSTextField?
  • Previous by thread: Re: Executing a very low-priority operation in iOS
  • Next by thread: Why can't I change the font used by an NSTextField?
  • Index(es):
    • Date
    • Thread