This commit changes the timer code to make the implementation robust
against late firing platform alarm case. In particular, it addresses
the (rare corner-case) scenario where alarm fire is late and the head
timer in the linked-list is already expired and then a new timer is
started with maximum interval. This can possibly violate the
requirement for `TimerScheduler::IsStringlyBefore()` method that the
two times being compared should not differ more than the maximum
interval `Timer::kMaxDt`. To address this, a new method
`Timer::DoesFireBefore()` is added to compare fire time of two timers
which checks for expired timers.
This commit also updates the timer unit test to add test cases related
to the late firing alarm.
This commit contains the following:
- It adds methods to `Message` to assign a priority level to messages.
Currently there are four priority levels: High, Medium, Low, VeryLow
but this is easily changeable.
- It introduces a new class `PriorityQueue` which implements a FIFO queue
for storing messages based on their priority level in addition to oder
in which they are added.
If the priority level of an already queued message in a `PriorityQueue`
is changed, the associated queue will automatically move the message
within the queue based on its new priority level.
Internally the implementation uses a circular doubly linked-list with
an array of tail pointers associated with different priority levels.
- It adds new methods and an `Iterator` class in `MessagePool` to access
the priority queue where all allocated and queued messages from this
pool are stored. The `Iterator` class allows bi-directional iteration
through the list (from highest priority to lowest or reverse).
- This commit also contain detailed unit-test for all the newly added
features/methods.
This commit makes the following changes:
- It adds a unit test for testing different `MessageQueue` operations.
- It modifies how the `MessageQueue` determines the lists (the `kListAll`
is maintained by the message pool and the `kListInterface` is accessed
from the `MessageQueue` associated with the list).
- It modifies the underlying list implementation to use a circular doubly
linked-list.