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 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]

Reply via email to