Re: NSThread to NSOperation and blockUntil
Re: NSThread to NSOperation and blockUntil
- Subject: Re: NSThread to NSOperation and blockUntil
- From: Jens Alfke <email@hidden>
- Date: Tue, 22 Mar 2016 11:06:47 -0400
> On Mar 22, 2016, at 2:33 AM, Trygve Inda <email@hidden> wrote:
>
> So I need to be able to have a process done in 30 seconds for example.... At
> full speed it could be done in 4 seconds but I'd like it done with as little
> impact as possible.
I don’t think it makes much difference to other system threads whether your thread takes 4 seconds or 30 to complete. Modern computers are almost never starved for CPU resources since they have a lot of cores and the OS is very good at fast context switching. On my MBP the only time the CPU meter fills up all the way is when Xcode is doing a clean build of a project, and even then I don’t notice other apps slowing down.
If you’re really worried, you can use that background quality-of-service level on your thread/queue, and the OS will just put your thread on ice while other threads are contending for all the CPU cores.
The resources that are more often limited are RAM and I/O. So it makes _much_ more of a difference to the rest of the system if your task uses a lot of memory or reads/writes a lot of data. In that case it could be advantageous to slow it down artificially, although you might get more bang for the buck by trying to optimize the algorithms to use less memory or I/O.
—Jens
_______________________________________________
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