TimerTaskDef moved out of Scheduler class, renamed to Event
This commit is contained in:
parent
998dad7e66
commit
648e9d5863
@ -53,10 +53,10 @@ import org.json.JSONObject;
|
|||||||
import opensesim.old_sesim.AutoTraderInterface;
|
import opensesim.old_sesim.AutoTraderInterface;
|
||||||
import opensesim.old_sesim.Exchange;
|
import opensesim.old_sesim.Exchange;
|
||||||
import opensesim.old_sesim.Scheduler;
|
import opensesim.old_sesim.Scheduler;
|
||||||
|
import opensesim.old_sesim.Scheduler.TimerTaskDef;
|
||||||
|
|
||||||
import opensesim.world.GodWorld;
|
import opensesim.world.GodWorld;
|
||||||
import opensesim.world.World;
|
import opensesim.world.World;
|
||||||
import opensesim.world.scheduler.Event;
|
|
||||||
|
|
||||||
import opensesim.world.scheduler.Scheduler.EventListener;
|
import opensesim.world.scheduler.Scheduler.EventListener;
|
||||||
|
|
||||||
@ -66,8 +66,7 @@ import opensesim.world.scheduler.Scheduler.EventListener;
|
|||||||
*/
|
*/
|
||||||
public class SeSimApplication extends javax.swing.JFrame {
|
public class SeSimApplication extends javax.swing.JFrame {
|
||||||
|
|
||||||
|
GodWorld godworld;
|
||||||
GodWorld godworld;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form NewMDIApplication
|
* Creates new form NewMDIApplication
|
||||||
@ -75,16 +74,14 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
public SeSimApplication() {
|
public SeSimApplication() {
|
||||||
|
|
||||||
Globals.setXClassLoader();
|
Globals.setXClassLoader();
|
||||||
Globals.setLookAndFeel(Globals.prefs.get(Globals.PrefKeys.LAF, "Nimbus"));
|
Globals.setLookAndFeel(Globals.prefs.get(Globals.PrefKeys.LAF, "Nimbus"));
|
||||||
// Globals.setLookAndFeel("Metal");
|
// Globals.setLookAndFeel("Metal");
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
JSONObject cfg;
|
JSONObject cfg;
|
||||||
cfg = new JSONObject(Globals.prefs.get("world","{}"));
|
cfg = new JSONObject(Globals.prefs.get("world", "{}"));
|
||||||
godworld = new GodWorld(cfg);
|
godworld = new GodWorld(cfg);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Get default screen and place our window
|
// Get default screen and place our window
|
||||||
// to the center of this screen
|
// to the center of this screen
|
||||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
@ -602,33 +599,17 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
JSONObject cfg = new JSONObject("{"
|
JSONObject cfg = new JSONObject("{"
|
||||||
+ "strategy: opensesim.trader.SimpleTrader"
|
+ "strategy: opensesim.trader.SimpleTrader"
|
||||||
+ "}");
|
+ "}");
|
||||||
// world.createTrader(cfg);
|
// world.createTrader(cfg);
|
||||||
|
|
||||||
opensesim.world.scheduler.Scheduler s = godworld.getScheduler();
|
opensesim.world.scheduler.Scheduler s = godworld.getScheduler();
|
||||||
|
|
||||||
class MyEvent extends Event {
|
|
||||||
int count = 0;
|
|
||||||
MyEvent(){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class MyListener implements EventListener{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class MyListener implements EventListener {
|
||||||
|
|
||||||
World world;
|
World world;
|
||||||
MyListener(World world){
|
|
||||||
this.world = world;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
MyListener(World world) {
|
||||||
public long receive(Event event) {
|
this.world = world;
|
||||||
MyEvent e = (MyEvent) event;
|
|
||||||
System.out.printf("Received an Event %d\n",e.count);
|
|
||||||
e.count++;
|
|
||||||
world.schedule(this, event, 1000);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -637,15 +618,23 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long receive(opensesim.world.scheduler.Event task) {
|
||||||
|
|
||||||
|
System.out.printf("Received an Event %d\n", 0);
|
||||||
|
// e.count++;
|
||||||
|
world.schedule(this, 1000);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MyListener listener = new MyListener(godworld.getWorld());
|
MyListener listener = new MyListener(godworld.getWorld());
|
||||||
MyEvent arg = new MyEvent();
|
// MyEvent arg = new MyEvent();
|
||||||
|
|
||||||
s.startTimerTask(listener, arg, WIDTH);
|
s.startTimerTask(listener, 1000);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
resetSim();
|
resetSim();
|
||||||
JSONObject jo = new JSONObject(Globals.prefs.get("Exchange", "{}"));
|
JSONObject jo = new JSONObject(Globals.prefs.get("Exchange", "{}"));
|
||||||
@ -679,8 +668,7 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
|
|
||||||
};
|
};
|
||||||
// Globals.se.timer.startTimerTask(tt, 0);
|
// Globals.se.timer.startTimerTask(tt, 0);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopSim() {
|
void stopSim() {
|
||||||
@ -973,17 +961,15 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
|
|
||||||
private void assetsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_assetsMenuItemActionPerformed
|
private void assetsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_assetsMenuItemActionPerformed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
opensesim.gui.AssetEditor.AssetListDialog dialog;
|
opensesim.gui.AssetEditor.AssetListDialog dialog;
|
||||||
dialog = new opensesim.gui.AssetEditor.AssetListDialog(godworld,this,true);
|
dialog = new opensesim.gui.AssetEditor.AssetListDialog(godworld, this, true);
|
||||||
dialog.setLocationRelativeTo(this);
|
dialog.setLocationRelativeTo(this);
|
||||||
dialog.setVisible(rootPaneCheckingEnabled);
|
dialog.setVisible(rootPaneCheckingEnabled);
|
||||||
dialog.dispose();
|
dialog.dispose();
|
||||||
}//GEN-LAST:event_assetsMenuItemActionPerformed
|
}//GEN-LAST:event_assetsMenuItemActionPerformed
|
||||||
|
|
||||||
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
|
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
|
||||||
JDialog dialog = new NewJDialog(this,true);
|
JDialog dialog = new NewJDialog(this, true);
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
dialog.dispose();
|
dialog.dispose();
|
||||||
|
|
||||||
@ -995,20 +981,18 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
ExchangeListDialog.runDialog(this, godworld);
|
ExchangeListDialog.runDialog(this, godworld);
|
||||||
|
|
||||||
}//GEN-LAST:event_exchangesMenuItemActionPerformed
|
}//GEN-LAST:event_exchangesMenuItemActionPerformed
|
||||||
public static class Pojo {
|
public static class Pojo {
|
||||||
|
|
||||||
public String getSymbol() {
|
|
||||||
return symbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public String symbol = "EUR";
|
|
||||||
public String name = "Euro";
|
|
||||||
};
|
|
||||||
|
|
||||||
|
public String getSymbol() {
|
||||||
|
return symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public String symbol = "EUR";
|
||||||
|
public String name = "Euro";
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args the command line arguments
|
* @param args the command line arguments
|
||||||
@ -1017,13 +1001,8 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
*/
|
*/
|
||||||
public static void main(String args[]) throws IllegalAccessException, InstantiationException {
|
public static void main(String args[]) throws IllegalAccessException, InstantiationException {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//opensesim.world.World.MasterApi mapi = new opensesim.world.World.MasterApi();
|
//opensesim.world.World.MasterApi mapi = new opensesim.world.World.MasterApi();
|
||||||
|
|
||||||
|
|
||||||
// testing
|
// testing
|
||||||
|
|
||||||
Pojo p = new Pojo();
|
Pojo p = new Pojo();
|
||||||
|
|
||||||
Gson g = new Gson();
|
Gson g = new Gson();
|
||||||
@ -1031,46 +1010,26 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
|
|
||||||
System.out.printf("GSON: %s\n", r);
|
System.out.printf("GSON: %s\n", r);
|
||||||
|
|
||||||
JSONObject o = new JSONObject(p,new String[]{"name","symbol"});
|
JSONObject o = new JSONObject(p, new String[]{"name", "symbol"});
|
||||||
System.out.printf("OJSON: %s\n", o.toString(8));
|
System.out.printf("OJSON: %s\n", o.toString(8));
|
||||||
|
|
||||||
|
// System.exit(0);
|
||||||
|
|
||||||
|
|
||||||
// System.exit(0);
|
|
||||||
|
|
||||||
|
|
||||||
// end testing
|
// end testing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Initialize globals
|
// Initialize globals
|
||||||
Class<?> c = opensesim.gui.SeSimApplication.class;
|
Class<?> c = opensesim.gui.SeSimApplication.class;
|
||||||
Globals.initGlobals(c);
|
Globals.initGlobals(c);
|
||||||
|
|
||||||
/* String world_source = Globals.prefs.get("world", "{}");
|
/* String world_source = Globals.prefs.get("world", "{}");
|
||||||
JSONObject world = new org.json.JSONObject(world_source);
|
JSONObject world = new org.json.JSONObject(world_source);
|
||||||
Globals.world.putConfig(world);
|
Globals.world.putConfig(world);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//Globals.installLookAndFeels();
|
//Globals.installLookAndFeels();
|
||||||
|
// Globals.setLookAndFeel("Metal");
|
||||||
// Globals.setLookAndFeel("Metal");
|
//JDialog.setDefaultLookAndFeelDecorated(true);
|
||||||
|
|
||||||
//JDialog.setDefaultLookAndFeelDecorated(true);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Globals.se = new Exchange();
|
Globals.se = new Exchange();
|
||||||
|
|
||||||
|
|
||||||
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, "");
|
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, "");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -38,7 +38,7 @@ import opensesim.sesim.interfaces.GetJson;
|
|||||||
import opensesim.util.Scollection;
|
import opensesim.util.Scollection;
|
||||||
import opensesim.util.SeSimException;
|
import opensesim.util.SeSimException;
|
||||||
import opensesim.util.idgenerator.IDGenerator;
|
import opensesim.util.idgenerator.IDGenerator;
|
||||||
import opensesim.world.scheduler.Event;
|
|
||||||
import opensesim.world.scheduler.Scheduler;
|
import opensesim.world.scheduler.Scheduler;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -51,8 +51,8 @@ import org.json.JSONObject;
|
|||||||
public class GodWorld implements GetJson, World {
|
public class GodWorld implements GetJson, World {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void schedule(Scheduler.EventListener listener, Event arg, long t) {
|
public void schedule(Scheduler.EventListener listener, long t) {
|
||||||
scheduler.startTimerTask(listener, arg, t);
|
scheduler.startTimerTask(listener, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class JKEYS {
|
public static final class JKEYS {
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package opensesim.world;
|
package opensesim.world;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import opensesim.world.scheduler.Event;
|
|
||||||
import opensesim.world.scheduler.Scheduler;
|
import opensesim.world.scheduler.Scheduler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,8 +61,8 @@ public class RealWorld implements World{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void schedule(Scheduler.EventListener listener, Event arg, long t) {
|
public void schedule(Scheduler.EventListener listener, long t) {
|
||||||
godworld.schedule(listener, arg, t);
|
godworld.schedule(listener, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package opensesim.world;
|
package opensesim.world;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import opensesim.world.scheduler.Event;
|
|
||||||
import opensesim.world.scheduler.Scheduler.EventListener;
|
import opensesim.world.scheduler.Scheduler.EventListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,5 +43,5 @@ public interface World {
|
|||||||
|
|
||||||
Collection<Trader> getTradersCollection();
|
Collection<Trader> getTradersCollection();
|
||||||
|
|
||||||
public void schedule(EventListener listener, Event arg, long t);
|
public void schedule(EventListener listener, long t);
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,32 @@
|
|||||||
*/
|
*/
|
||||||
package opensesim.world.scheduler;
|
package opensesim.world.scheduler;
|
||||||
|
|
||||||
|
import opensesim.world.scheduler.Scheduler.EventListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author 7u83 <7u83@mail.ru>
|
* @author 7u83 <7u83@mail.ru>
|
||||||
*/
|
*/
|
||||||
public class Event {
|
public class Event {
|
||||||
|
|
||||||
}
|
EventListener listener;
|
||||||
|
|
||||||
|
|
||||||
|
long curevtime;
|
||||||
|
long newevtime;
|
||||||
|
// int id;
|
||||||
|
|
||||||
|
Event(EventListener listener, long t) {
|
||||||
|
this.listener = listener;
|
||||||
|
|
||||||
|
newevtime = t;
|
||||||
|
// id = nextTimerTask.getAndAdd(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @Override
|
||||||
|
public int compareTo(Object o) {
|
||||||
|
return ((TimerTaskDef) o).id - this.id;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
@ -27,12 +27,9 @@ package opensesim.world.scheduler;
|
|||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.SortedSet;
|
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@ -57,14 +54,14 @@ public class Scheduler extends Thread {
|
|||||||
return this.acceleration;
|
return this.acceleration;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final SortedMap<Long, LinkedList<TimerTaskDef>> event_queue = new TreeMap<>();
|
private final SortedMap<Long, LinkedList<Event>> event_queue = new TreeMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface EventListener {
|
public interface EventListener {
|
||||||
|
|
||||||
long receive(Event event);
|
long receive(Event task);
|
||||||
|
|
||||||
long getID();
|
long getID();
|
||||||
}
|
}
|
||||||
@ -149,7 +146,7 @@ public class Scheduler extends Thread {
|
|||||||
|
|
||||||
AtomicInteger nextTimerTask = new AtomicInteger(0);
|
AtomicInteger nextTimerTask = new AtomicInteger(0);
|
||||||
|
|
||||||
public class TimerTaskDef implements Comparable {
|
/* public class TimerTaskDef {
|
||||||
|
|
||||||
EventListener listener;
|
EventListener listener;
|
||||||
Event arg;
|
Event arg;
|
||||||
@ -166,15 +163,12 @@ public class Scheduler extends Thread {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(Object o) {
|
|
||||||
return ((TimerTaskDef) o).id - this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
//LinkedList<TimerTaskDef> set_tasks = new LinkedList<>();
|
//LinkedList<TimerTaskDef> set_tasks = new LinkedList<>();
|
||||||
ConcurrentLinkedQueue<TimerTaskDef> new_tasks = new ConcurrentLinkedQueue<>();
|
ConcurrentLinkedQueue<Event> new_tasks = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -182,11 +176,11 @@ public class Scheduler extends Thread {
|
|||||||
* @param time
|
* @param time
|
||||||
* @return The TimerTask created
|
* @return The TimerTask created
|
||||||
*/
|
*/
|
||||||
public TimerTaskDef startTimerTask(EventListener listener, Event arg, long time) {
|
public Event startTimerTask(EventListener listener, long time) {
|
||||||
|
|
||||||
long evtime = time + currentTimeMillis();
|
long evtime = time + currentTimeMillis();
|
||||||
|
|
||||||
TimerTaskDef task = new TimerTaskDef(listener,arg, evtime);
|
Event task = new Event(listener, evtime);
|
||||||
new_tasks.add(task);
|
new_tasks.add(task);
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
@ -195,7 +189,7 @@ public class Scheduler extends Thread {
|
|||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rescheduleTimerTask(TimerTaskDef task, long time) {
|
public void rescheduleTimerTask(Event task, long time) {
|
||||||
long evtime = time + currentTimeMillis();
|
long evtime = time + currentTimeMillis();
|
||||||
task.newevtime = evtime;
|
task.newevtime = evtime;
|
||||||
new_tasks.add(task);
|
new_tasks.add(task);
|
||||||
@ -229,11 +223,11 @@ public class Scheduler extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HashMap<TimerTaskDef, Long> tasks = new HashMap<>();
|
// HashMap<TimerTaskDef, Long> tasks = new HashMap<>();
|
||||||
private boolean addTimerTask(TimerTaskDef e) {
|
private boolean addTimerTask(Event e) {
|
||||||
|
|
||||||
// System.out.printf("Add TimerTask %d %d\n",e.curevtime,e.newevtime);
|
// System.out.printf("Add TimerTask %d %d\n",e.curevtime,e.newevtime);
|
||||||
// long evtime = time + currentTimeMillis();
|
// long evtime = time + currentTimeMillis();
|
||||||
LinkedList<TimerTaskDef> s = event_queue.get(e.newevtime);
|
LinkedList<Event> s = event_queue.get(e.newevtime);
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
s = new LinkedList<>();
|
s = new LinkedList<>();
|
||||||
event_queue.put(e.newevtime, s);
|
event_queue.put(e.newevtime, s);
|
||||||
@ -251,13 +245,13 @@ public class Scheduler extends Thread {
|
|||||||
cancel_queue.add(e);
|
cancel_queue.add(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelMy(TimerTaskDef e) {
|
private void cancelMy(Event e) {
|
||||||
|
|
||||||
// Long evtime = tasks.get(e.curevtime);
|
// Long evtime = tasks.get(e.curevtime);
|
||||||
// if (evtime == null) {
|
// if (evtime == null) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
LinkedList<TimerTaskDef> s = event_queue.get(e.curevtime);
|
LinkedList<Event> s = event_queue.get(e.curevtime);
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
// System.out.printf("My not found\n");
|
// System.out.printf("My not found\n");
|
||||||
return;
|
return;
|
||||||
@ -299,13 +293,13 @@ public class Scheduler extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if (t <= ct) {
|
// if (t <= ct) {
|
||||||
LinkedList<TimerTaskDef> s = event_queue.get(t);
|
LinkedList<Event> s = event_queue.get(t);
|
||||||
Object rc;
|
Object rc;
|
||||||
rc = event_queue.remove(t);
|
rc = event_queue.remove(t);
|
||||||
|
|
||||||
while (s.size() > 0) {
|
while (s.size() > 0) {
|
||||||
TimerTaskDef def = s.pop();
|
Event def = s.pop();
|
||||||
long next_t = this.fireEvent(def.listener,def.arg);
|
long next_t = this.fireEvent(def.listener,def);
|
||||||
if (next_t == -1)
|
if (next_t == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -363,7 +357,7 @@ public class Scheduler extends Thread {
|
|||||||
while (!terminate) {
|
while (!terminate) {
|
||||||
|
|
||||||
while (!new_tasks.isEmpty()) {
|
while (!new_tasks.isEmpty()) {
|
||||||
TimerTaskDef td = new_tasks.poll();
|
Event td = new_tasks.poll();
|
||||||
// System.out.printf("There is a set task %d %d\n",td.curevtime,td.newevtime);
|
// System.out.printf("There is a set task %d %d\n",td.curevtime,td.newevtime);
|
||||||
|
|
||||||
this.cancelMy(td);
|
this.cancelMy(td);
|
||||||
|
Loading…
Reference in New Issue
Block a user