Quote:
Originally Posted by omalleyj
Hard to say without looking in detail. You have the constant tests for setting and checking vs. the context switch to handle the thread.
|
Your "polling" code (a form of state machine as shown) runs once every 20ms yes? While you're waiting for the 2 seconds to elapse, you're doing one simple conditional jump every 20ms.
If CPU usage becomes a problem using this approach, there's probably something seriously wrong elsewhere in the code.