some tests

This commit is contained in:
7u83 2017-03-13 19:26:39 +01:00
parent 5cf177a346
commit 3ddf431c48
2 changed files with 26 additions and 29 deletions

View File

@ -128,20 +128,14 @@ public class Scheduler extends Thread {
// this.cur_nano += (((double)diff_nano)/1000000.0)*this.acceleration; // this.cur_nano += (((double)diff_nano)/1000000.0)*this.acceleration;
// return (long)(cur_nano/1000000.0); // return (long)(cur_nano/1000000.0);
this.current_nanos += (double) diff * (double) this.acceleration; this.current_nanos += (double) diff * (double) this.acceleration;
// this.current_time_millis += ((double) diff) * this.acceleration; // this.current_time_millis += ((double) diff) * this.acceleration;
this.current_time_millis = this.current_nanos / 1000000.0; this.current_time_millis = this.current_nanos / 1000000.0;
return (long) this.current_time_millis; return (long) this.current_time_millis;
} }
/** /**
* *
* @return * @return
@ -175,10 +169,6 @@ public class Scheduler extends Thread {
return (long) this.current_time_millis; return (long) this.current_time_millis;
} }
public long currentTimeMillis() { public long currentTimeMillis() {
// return (long)(cur_nano/1000000.0); // return (long)(cur_nano/1000000.0);
return (long) this.current_time_millis; return (long) this.current_time_millis;
@ -327,7 +317,6 @@ public class Scheduler extends Thread {
long t = event_queue.firstKey(); long t = event_queue.firstKey();
long ct = currentTimeMillis1(); long ct = currentTimeMillis1();
// ct = t; // ct = t;
if (t > ct) { if (t > ct) {
//if ((long) diff > 0) { //if ((long) diff > 0) {
@ -345,12 +334,20 @@ public class Scheduler extends Thread {
} }
// if (t <= ct) { // if (t <= ct) {
SortedSet s = event_queue.get(t); SortedSet s = event_queue.get(t);
Object rc = event_queue.remove(t); Object rc = event_queue.remove(t);
if (s.size() > 1) {
System.out.printf("Events in a row: %d\n", s.size());
}
Iterator<TimerTaskDef> it = s.iterator(); Iterator<TimerTaskDef> it = s.iterator();
while (it.hasNext()) { while (it.hasNext()) {
TimerTaskDef e = it.next(); TimerTaskDef e = it.next();
if (s.size() > 1) {
System.out.printf("Sicku: %d %d\n", e.id, e.curevtime);
}
long next_t = this.fireEvent(e.taskRunner); long next_t = this.fireEvent(e.taskRunner);
e.newevtime = next_t + t; e.newevtime = next_t + t;
this.addTimerTask(e); this.addTimerTask(e);