Multitasking in Mac OS Gets 100% CPU
- Posted by bryanso Nov 05, 2012
- 1603 views
The following naive implementation of get_key with multitasking support causes 100% CPU in Mac OS (Mountain Lion, Eu 4.0.4). Is there a better practice? This does not cause high CPU usage in Windows 7.
Is there something I can do in Mac OS to reduce the CPU consumption?
function editor_wait_key() atom c = -1 while c = -1 do c = get_key() task_yield() end while return c end function
Changing task_yield to task_delay or even sleep still has the same problem:
function editor_wait_key() atom c = -1 while c = -1 do c = get_key() task_delay(0.05) -- sleep(0.01) end while return c end function
Thanks