new scheduler still not working
This commit is contained in:
parent
2cf4780909
commit
e77f832045
@ -1,4 +1,4 @@
|
|||||||
#Wed, 19 Dec 2018 18:53:48 +0100
|
#Thu, 20 Dec 2018 09:38:26 +0100
|
||||||
annotation.processing.enabled=true
|
annotation.processing.enabled=true
|
||||||
annotation.processing.enabled.in.editor=false
|
annotation.processing.enabled.in.editor=false
|
||||||
annotation.processing.processors.list=
|
annotation.processing.processors.list=
|
||||||
|
@ -87,7 +87,7 @@ public class SimpleTrader extends AbstractTrader implements EventListener{
|
|||||||
@Override
|
@Override
|
||||||
public long receive(Event task) {
|
public long receive(Event task) {
|
||||||
System.out.printf("Here we are !!! %f\n", getWorld().randNextFloat(12f, 27f));
|
System.out.printf("Here we are !!! %f\n", getWorld().randNextFloat(12f, 27f));
|
||||||
// getWorld().schedule(this, 100);
|
getWorld().schedule(this, 5000);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class Scheduler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event e = getNextEvent();
|
Event e = getNextEvent();
|
||||||
if (e==null){
|
if (e == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,12 +92,23 @@ public class Scheduler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Event startTimerTask(EventListener listener, long time) {
|
public Event startTimerTask(EventListener listener, long time) {
|
||||||
// Event e = schedulers.get(next++).startTimerTask(listener, time);
|
Event e = new Event(listener);
|
||||||
// if (next == schedulers.size()) {
|
long t = time + clock.currentTimeMillis();
|
||||||
// next = 0;
|
synchronized (event_queue) {
|
||||||
// }
|
LinkedList<Event> s = event_queue.get(t);
|
||||||
return null;
|
if (s == null) {
|
||||||
|
s = new LinkedList<>();
|
||||||
|
event_queue.put(t, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
s.add(e);
|
||||||
|
}
|
||||||
|
synchronized (clock) {
|
||||||
|
clock.notifyAll();
|
||||||
|
}
|
||||||
|
return e;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected long getDelay() {
|
protected long getDelay() {
|
||||||
|
Loading…
Reference in New Issue
Block a user