Mercurial > hg > RemoteEditor > REPSessionManager
diff rep/ServerMainLoop.java @ 399:19705f4b8015
waitingCommandInMerge
author | one |
---|---|
date | Mon, 24 Nov 2008 23:11:51 +0900 |
parents | 3b0a5a55e3ee |
children | 2cf5392b2a9f |
line wrap: on
line diff
--- a/rep/ServerMainLoop.java Sun Nov 23 18:38:52 2008 +0900 +++ b/rep/ServerMainLoop.java Mon Nov 24 23:11:51 2008 +0900 @@ -6,7 +6,6 @@ import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectionKey; import java.util.LinkedList; -import java.util.List; import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; @@ -28,7 +27,6 @@ public SessionManager manager; protected SessionManagerGUI gui; protected REPSelector<REPCommand> selector; - protected List<PacketSet> waitingCommandInMerge= new LinkedList<PacketSet>(); private BlockingQueue<SessionManagerEvent> waitingEventQueue = new LinkedBlockingQueue<SessionManagerEvent>(); public String myHost; @@ -54,7 +52,7 @@ public void mainLoop() throws IOException { while(true){ - checkWaitingCommandInMerge(); + manager.checkWaitingCommandInMerge(); if (checkInputEvent() || checkWaitingWrite()) { // try to do fair execution for waiting task @@ -103,44 +101,8 @@ return false; } - /** - * Check waiting command in merge - * @return true if there is a processed waiting command - * @throws IOException - */ - public void checkWaitingCommandInMerge() { - List<PacketSet> w = waitingCommandInMerge; - waitingCommandInMerge = new LinkedList<PacketSet>(); - for(PacketSet p: w) { - REPNode e = p.getEditor(); - if(e.isMerging()) { // still merging do nothing - waitingCommandInMerge.add(p); - } else { - try { -// if (manager.sessionManage(e, p.command)) { // we don't need this -// assert false; -// return; -// } - e.manage(p.command); - } catch (Exception e1) { - // should be e.close()? - close(p.channel); - } - } - } - } - - public boolean hasWaitingCommand(REPSocketChannel<REPCommand>c) { - for(PacketSet p:waitingCommandInMerge) { - if (p.channel==c) { - return true; - } - } - return false; - } - - private void close(REPSocketChannel<REPCommand> channel) { + public void close(REPSocketChannel<REPCommand> channel) { REPSelectionKey<REPCommand>key = channel.keyFor1(selector); REPNode handler = (REPNode)key.attachment(); key.cancel(); @@ -223,9 +185,6 @@ } } - public void addWaitingCommand(PacketSet set) { - waitingCommandInMerge.add(set); - } public void buttonPressed(SessionManagerEvent event) { try {