SnabbCo/snabbswitch — pull request #316 by eugeneia (2014-11-13 14:59:40+00:00)
Title: [lib.timer] Remove `core.timer' and supply a `lib.timer'

[lib.timer] Remove `core.timer` and supply a `lib.timer` instead, which re-implements `core.timer` in an app-local fashion.

Adapted (and removed some, now impossible?) uses of `core.timer`.

After #302 lead to headaches this PR goes a different road. It changes the timer implementation quite a bit, so any auditing would be appreciated. Did I mention how I am especially scared of time? Most unpredictable concept in the universe.

**Notes:**

This uses `engine.now()` to get the "time". Which returns the number of seconds since 1970 *as a floating point number with up to 5 digitis of precision* **as far as I can tell**. So what I do is multiply by 1.000 and expect to get *milliseconds*.

I had to remove some uses (top level reporting timers in designs and selftests), since you kind of need an app with a pull method now to insert your `timers:run()`.

The interface of `lib.timer` goes like this (by example):

```
local timers = require("lib.timer").TimerTable.new()

timers:activate(
timers:timer( -- This was `timer.new(...)' before.
"name",
,
, -- This parameter changed to milliseconds (instead of nanoseconds)
'repeating')
)

timers:run() -- Call this e.g. in `pull()'
```