Mercurial > hg > Database > Alice
view src/alice/topology/manager/keeparive/PingSchedList.java @ 304:366742c2b07d
divide list from Scheduler
author | sugi |
---|---|
date | Tue, 19 Nov 2013 14:35:33 +0900 |
parents | |
children | 098e97954c08 |
line wrap: on
line source
package alice.topology.manager.keeparive; import java.util.LinkedList; public class PingSchedList { private LinkedList<TaskInfo> list = new LinkedList<TaskInfo>(); public LinkedList<TaskInfo> getTaskList(){ return list; } public synchronized void addTask(TaskInfo newInfo){ if (list.isEmpty()) { list.add(newInfo); } else { int cnt = 0; for (TaskInfo info : list){ if (info.getSleepTime() < newInfo.getSleepTime()){ newInfo.setSleepTime(newInfo.getSleepTime() - info.getSleepTime()); } else if (info.getSleepTime() == newInfo.getSleepTime()){ newInfo.setSleepTime(newInfo.getSleepTime() - info.getSleepTime()); cnt++; break; } else if (info.getSleepTime() > newInfo.getSleepTime()){ info.setSleepTime(info.getSleepTime() - newInfo.getSleepTime()); break; } cnt++; } list.add(cnt, newInfo); } } }