huntlabs / hunt

A refined core library for D programming language. The module has concurrency / collections / event / io / logging / text / serialization and more.
Apache License 2.0
95 stars 15 forks source link

Timer always runs every 1 second #12

Closed Kripth closed 6 years ago

Kripth commented 6 years ago

It seems that the KissTimer in package kiss.util.timer always runs every 1 second, regardless of the Duration passed to the constructor.

I have tested on Windows 10 with the following program:

import std.datetime : StopWatch, seconds;
import std.stdio : writeln;
import kiss.event : EventLoop;
import kiss.util.timer : KissTimer;

EventLoop eventLoop = new EventLoop();

StopWatch watch = StopWatch();
watch.start();

KissTimer timer = new KissTimer(eventLoop, 10.seconds);
timer.onTick((Object sender){ writeln(watch.peek.msecs); });
timer.start();

eventLoop.run();
zoujiaqing commented 6 years ago

waiting for @Heromyth to review and testing this question.

Heromyth commented 6 years ago

Thanks! It fixed in https://github.com/huntlabs/kiss/commit/bcfaba9ae485dd5bc1487103b54fa60119d3239e.