Mercurial > hg > Members > sugi > javafx
changeset 34:4ddef9b2e1aa
bug fixed
author | sugi |
---|---|
date | Mon, 11 Nov 2013 18:36:34 +0900 |
parents | f5cf57c645ab |
children | 9638020264cd |
files | src/alice/topology/manager/keeparive/PingScheduler.java |
diffstat | 1 files changed, 20 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/topology/manager/keeparive/PingScheduler.java Mon Nov 11 17:13:41 2013 +0900 +++ b/src/alice/topology/manager/keeparive/PingScheduler.java Mon Nov 11 18:36:34 2013 +0900 @@ -37,22 +37,26 @@ nextTask.setTime(postponeTime + nextTask.getTime()); nowTask.setTime(INTERVAL); addTask(nowTask); + } else { + nowTask.setTime(postponeTime); + list.add(0, nowTask); + for (int cnt = 0 ;cnt < list.size(); cnt++){ TaskInfo task = list.get(cnt); if (name.equals(task.getName())){ - if (cnt+1 < list.size()){ + if (cnt+1 < list.size()){ TaskInfo tasknext = list.get(cnt+1); tasknext.setTime(task.getTime()); - } - list.remove(cnt); + } + list.remove(task); task.setTime(INTERVAL); addTask(task); - postponeFlag = true; break; } } } + postponeFlag = true; notify(); } @@ -68,24 +72,22 @@ if (list.isEmpty()) { list.add(newInfo); } else { - for (int cnt = 0; cnt < list.size(); cnt++){ - TaskInfo info = list.get(cnt); + int cnt = 0; + for (TaskInfo info : list){ if (info.getTime() < newInfo.getTime()){ - newInfo.setTime(newInfo.getTime() - info.getTime()); - if (cnt+1 == list.size()){ - list.add(newInfo); - break; - } + newInfo.setTime(newInfo.getTime() - info.getTime()); } else if (info.getTime() == newInfo.getTime()){ newInfo.setTime(newInfo.getTime() - info.getTime()); - list.add(cnt+1, newInfo); + cnt++; break; } else if (info.getTime() > newInfo.getTime()){ info.setTime(info.getTime() - newInfo.getTime()); - list.add(cnt, newInfo); break; } + cnt++; } + + list.add(cnt, newInfo); } updateFlag = true; } @@ -95,17 +97,17 @@ try { while(true){ if(list.size()== 0)System.exit(0); + for (TaskInfo info : list){ + System.out.println(info.getName() +" "+info.getTime()); + } nowTask = list.poll(); System.out.print("taskNum "+nowTask.getTaskNum()); System.out.println(" taskTime "+nowTask.getTime()); time = System.currentTimeMillis(); if (nowTask.getTime()!=0) this.wait(nowTask.getTime()); - if (postponeFlag){ - nowTask.setTime(postponeTime); - list.add(0, nowTask); - updateFlag = true; - postponeFlag = false; + if (postponeFlag){ + postponeFlag = false; } else { totalTime +=nowTask.getTime(); nowTask.setTime(INTERVAL);