darach / eep-js

eep.js - Embedded Event Processing
MIT License
217 stars 33 forks source link

Monotonic and Periodic windows are identical #6

Closed ifesdjeen closed 11 years ago

ifesdjeen commented 11 years ago

Hi,

I've noticed that monotonic and periodic windows are identical right now. It's not entirely true though, because monotonic, if I understand underlying idea correctly, should not receive clock in it's constructor. Instead, it should set monotonic clock by default, and periodic should use wall clock.

Is this behavior intended?

darach commented 11 years ago

I was going to leave it open to different clock implementations with periodic defaulting to wall clock. The code is equivalent but I don't consider them the same. A clock used with monotonic should be (at least as far as I was thinking myself, ...) monotonic increasing. No such property is required of periodic. I guess it implies generally but not strictly increasing there - so should be tolerant of synchronisation such as via ntp force update.

I tend to use monotonic or logical clocks more than wall clock as wall clock is harder to test. If I built a backtesting environment I would want to replay historic events, for example, I may want to use simulation time or speed up or slow down time for whatever reason. I may want to perturb events. I could see folk wanting to reverse time. The aggregates are reversible so this is possible. My needs are fairly pedestrian and 'forward looking'. It would be cool if someone had a use case to move backwards through time. I would enjoy seeing that develop as long as I could still move time forwards...

ifesdjeen commented 11 years ago

Thanks for explanation! Now I understand.