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.in.editor=false
|
||||
annotation.processing.processors.list=
|
||||
|
@ -87,7 +87,7 @@ public class SimpleTrader extends AbstractTrader implements EventListener{
|
||||
@Override
|
||||
public long receive(Event task) {
|
||||
System.out.printf("Here we are !!! %f\n", getWorld().randNextFloat(12f, 27f));
|
||||
// getWorld().schedule(this, 100);
|
||||
getWorld().schedule(this, 5000);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -62,10 +62,10 @@ public class Scheduler {
|
||||
}
|
||||
}
|
||||
Event e = getNextEvent();
|
||||
if (e==null){
|
||||
if (e == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
e.listener.receive(e);
|
||||
}
|
||||
}
|
||||
@ -92,12 +92,23 @@ public class Scheduler {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized Event startTimerTask(EventListener listener, long time) {
|
||||
// Event e = schedulers.get(next++).startTimerTask(listener, time);
|
||||
// if (next == schedulers.size()) {
|
||||
// next = 0;
|
||||
// }
|
||||
return null;
|
||||
public Event startTimerTask(EventListener listener, long time) {
|
||||
Event e = new Event(listener);
|
||||
long t = time + clock.currentTimeMillis();
|
||||
synchronized (event_queue) {
|
||||
LinkedList<Event> s = event_queue.get(t);
|
||||
if (s == null) {
|
||||
s = new LinkedList<>();
|
||||
event_queue.put(t, s);
|
||||
}
|
||||
|
||||
s.add(e);
|
||||
}
|
||||
synchronized (clock) {
|
||||
clock.notifyAll();
|
||||
}
|
||||
return e;
|
||||
|
||||
}
|
||||
|
||||
protected long getDelay() {
|
||||
|
Loading…
Reference in New Issue
Block a user