Commit Graph

7 Commits

Author SHA1 Message Date
Jan Pochyla e9d7c3ea0e modutimeq: Add peektime() function (provisional).
Allows to get event time for a head item in the queue. The usecase
if waiting for the next event *OR* I/O completion. I/O completion may
happen before event triggers, and then wait should continue for the
remaining event time (or I/O completion may schedule another earlier
event altogether).

The new function has a strongly provisional status - it may be converted
to e.g. peek() function returning all of the event fields, not just time.
2017-03-29 18:18:35 +03:00
Paul Sokolovsky 830ce74f32 extmod/modutimeq: Make scheduling fair (round-robin).
By adding back monotonically increasing field in addition to time field.
As heapsort is not stable, without this, among entried added and readded
at the same time instant, some might be always selected, and some might
never be selected, leading to scheduling starvation.
2017-03-07 09:34:09 +01:00
Paul Sokolovsky 7327966da7 extmod/modutimeq: Make time_less_than be actually "less than", not less/eq.
This fixes an obvious case of non-fair scheduling of 2 tasks with the same
deadline.
2016-12-24 00:06:29 +03:00
Paul Sokolovsky 18f12caafc extmod/modutimeq: Fix printf in dump(). 2016-12-23 21:11:19 +03:00
Paul Sokolovsky 1b44987d0c extmod/modutimeq: Fix warning about unused param. 2016-12-22 00:48:19 +03:00
Paul Sokolovsky d02f6a9956 extmod/modutimeq: Refactor into optimized class.
import utimeq, utime
    # Max queue size, the queue allocated statically on creation
    q = utimeq.utimeq(10)
    q.push(utime.ticks_ms(), data1, data2)
    res = [0, 0, 0]
    # Items in res are filled up with results
    q.pop(res)
2016-12-22 00:29:32 +03:00
Paul Sokolovsky ef23399e32 extmod/modutimeq: Copy of current moduheapq with timeq support for refactoring. 2016-12-22 00:23:11 +03:00