Cooperate with PowerDevil and wait for alarm instead of frequently check on them
Why
We currently check if an alarm needs to be rung every two seconds. This method not only consume CPU cycle and won't work if the user space is frozen. With the incoming powerdevil feature, one can schedule powerdevil to wake up from suspend.
How
- a new thread for waiting an alarm.
- schedule next alarm to ring to powerdevil
If any of the following happened, re-schedule alarm to be waited
- at startup
- a new alarm is added
- an alarm is changed
- an alarm has been rung
in this way, we are saving the CPU cycle, and the precision is improved. Also less work if we want to inform user about a coming alarm.