Mercurial > hg > RemoteEditor > REPSessionManager
diff rep/SessionManager.java @ 328:6ceb222570cb
merge is working now.
author | kono |
---|---|
date | Sat, 11 Oct 2008 22:23:45 +0900 |
parents | 7b6dede07f4a |
children | a2624f6f7d0d |
line wrap: on
line diff
--- a/rep/SessionManager.java Sat Oct 11 19:31:13 2008 +0900 +++ b/rep/SessionManager.java Sat Oct 11 22:23:45 2008 +0900 @@ -115,9 +115,9 @@ public void mainLoop() throws IOException { while(true){ + checkWaitingCommandInMerge(); if (checkInputEvent() || - checkWaitingWrite() || - checkWaitingCommandInMerge()) { + checkWaitingWrite()) { // try to do fair execution for waiting task if(selector.selectNow() > 0) select(); continue; @@ -151,15 +151,22 @@ * @return true if there is a processed waiting command * @throws IOException */ - private boolean checkWaitingCommandInMerge() throws IOException { - for(Iterator<PacketSet> it = waitingCommandInMerge.iterator(); it.hasNext();){ - PacketSet p = it.next(); - if(p.getEditor().isMerging()) { // still merging do nothing - continue; - }else{ - // process one command and return true - manage(p.channel, p.command); - it.remove(); + private void checkWaitingCommandInMerge() throws IOException { + List<PacketSet> w = waitingCommandInMerge; + waitingCommandInMerge = new LinkedList<PacketSet>(); + for(PacketSet p: w) { + Editor e = p.getEditor(); + if(e!=null &&e.isMerging()) { // still merging do nothing + waitingCommandInMerge.add(p); + } else { + manage(p.channel, p.command); + } + } + } + + public boolean hasWaitingCommand(REPSocketChannel<REPCommand>c) { + for(PacketSet p:waitingCommandInMerge) { + if (p.channel==c) { return true; } } @@ -205,6 +212,12 @@ Session s = getSession(receivedCommand.sid); Editor e = s.getEditor(channel); // if(e==null) throw new IOException(); + if (receivedCommand.eid!=REP.MERGE_EID.id && receivedCommand.eid!=e.eid ) { + if (hasWaitingCommand(channel)) { + addWaitingCommand(new PacketSet(channel, e, receivedCommand)); + return; + } + } e.manage(receivedCommand); }