开发者

MPProcessors is deprecated in Mac OS 10.7. What's the alternative?

I am working on a fractal rendering app who's code dates back to 10.4. It uses NSThreads to manage rendering threads to calculate fractals.

Up until recently, it supported OSes back to 10.4, so I could not even upgrade it to use NSOperationQueues.

The app, FractalWorks, is now available in the Mac App store, who's minimum OS requirement is 10.6.6. Thus, we have abandonded support for older OSes, and will go back and rework the rendering to use NSOperationQueues or GCD.

In the meantime, I want to get it up and running cleanly in the newly released Lion. Specifically, I want to get rid of the long list calls that are newly deprecated in 10.7. This first pass will be a bare-bones upgrade.

The app currently uses the MPProcessors method to determine the number of cores on the system, so it can create a rendering thread for each core. It works fine, and MPProcessors even allows for hyperthreading on the i5/i7, and lets the program create double as many rendering threads as there are cores.

I need a modern call that will let me query the system for the number of logical cores, exactly as MPProcessors does now. The docs simply say that the method is deprecated, without offering an alternative. What IS the alternative? (And don't tell me GCD/NSOperationQueues. I know that's the way to go, but that is a bigger job than I am prepared to take on right now.)

Thanks in advance,

Duncan Champney 开发者_如何学编程WareTo


In Cocoa: [NSProcessInfo processInfo].processorCount

In BSD-ese: sysctlbyname("hw.ncpu", ...)

With Gestalt: Gestalt(gestaltCountOfCPUs, &count);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜