Mercurial > hg > Database > Alice
changeset 10:5f7cce38b25c
bug fix for wait command
author | one |
---|---|
date | Thu, 12 Jan 2012 19:51:11 +0900 |
parents | 22afbb2919f1 |
children | 2ea5acb0ed16 |
files | src/alice/datasegment/DataSegmentKey.java src/alice/test/codesegment/TestCodeSegment.java |
diffstat | 2 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/datasegment/DataSegmentKey.java Thu Jan 12 19:28:50 2012 +0900 +++ b/src/alice/datasegment/DataSegmentKey.java Thu Jan 12 19:51:11 2012 +0900 @@ -1,6 +1,7 @@ package alice.datasegment; import java.util.ArrayList; +import java.util.LinkedList; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.atomic.AtomicInteger; @@ -39,15 +40,20 @@ DataSegmentValue dsv = new DataSegmentValue(index, cmd.val); dataList.add(dsv); // run waiting peek and take + LinkedList<Command> removeList = new LinkedList<Command>(); for (Command waitCmd : waitList) { if (waitCmd.index < index) { waitCmd.manager.replyQueue.put(new Reply(waitCmd.seq, index, cmd.val)); + removeList.add(waitCmd); if (waitCmd.cmdType == CommandType.TAKE) { // delete data, if it run take cmd. dataList.remove(dsv); break; } } } + for (Command rmCmd : removeList) { + waitList.remove(rmCmd); + } break; case PEEK: if (cmd.index >= tailIndex.get()) {
--- a/src/alice/test/codesegment/TestCodeSegment.java Thu Jan 12 19:28:50 2012 +0900 +++ b/src/alice/test/codesegment/TestCodeSegment.java Thu Jan 12 19:51:11 2012 +0900 @@ -18,7 +18,7 @@ if (data.index == 10) return; CodeSegment cs = new TestCodeSegment(); - cs.ids.peek("arg1", "local", "key1", data.index); + cs.ids.take("arg1", "local", "key1", data.index); cs.ids.execute(); Value val = ValueFactory.createRawValue("String data");