I’m porting an Android app I made to iOS. Android has a Yield() function to move the thread from running to the back(?) of the thread queue. This is useful so that this thread doesn’t hog up too much CPU and make everything else sluggish. It works well in my Android app.
I’m using NSInvocationOperation objects to implement my threads. How do I add functionality similar to Android’s (POSIX’s) Yield()?
This doesn’t make a lot of sense. NSOperations are run in a thread, but they are not threads themselves, nor would they let you implement anything equivalent to a thread. If you really want a thread, use
NSThreadorpthread.If you really want POSIX, try
sched_yield(). At a higher level, there’spthread_yield_np()(np means non-portable — there is nopthread_yield()in POSIX) — but that does nothing but callsched_yield().I wouldn’t bother until you find that you actually need this, and that it helps. It’s not at all common to do this sort of thing in iOS or Mac apps.