Notifier: properly reset HAL alarm in non-periodic case (#1296)

The loop spins otherwise.
This commit is contained in:
Peter Johnson
2018-09-03 16:07:23 -07:00
committed by GitHub
parent 0b113ad9ce
commit 67b1c85315
3 changed files with 30 additions and 5 deletions

View File

@@ -60,13 +60,22 @@ public class Notifier implements AutoCloseable {
/**
* Update the alarm hardware to reflect the next alarm.
*
* @param triggerTime the time at which the next alarm will be triggered
*/
private void updateAlarm() {
private void updateAlarm(long triggerTime) {
int notifier = m_notifier.get();
if (notifier == 0) {
return;
}
NotifierJNI.updateNotifierAlarm(notifier, (long) (m_expirationTime * 1e6));
NotifierJNI.updateNotifierAlarm(notifier, triggerTime);
}
/**
* Update the alarm hardware to reflect the next alarm.
*/
private void updateAlarm() {
updateAlarm((long) (m_expirationTime * 1e6));
}
/**
@@ -97,6 +106,9 @@ public class Notifier implements AutoCloseable {
if (m_periodic) {
m_expirationTime += m_period;
updateAlarm();
} else {
// need to update the alarm to cause it to wait again
updateAlarm((long) -1);
}
} finally {
m_processLock.unlock();