Mercurial > hg > Members > nobuyasu > Alice > DPPAlice
view src/alice/test/dpp/codesegment/PutForkCodeSegment.java @ 20:6018e62cb198 dead lock dpp
modified
author | one |
---|---|
date | Sun, 09 Dec 2012 23:09:04 +0900 |
parents | 92cde6277018 |
children | fd370b35fac1 |
line wrap: on
line source
package alice.test.dpp.codesegment; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; import alice.test.dpp.datasegment.Fork; import alice.test.dpp.datasegment.Philosophy; public class PutForkCodeSegment extends CodeSegment { Receiver arg1 = ids.create(CommandType.TAKE); Receiver arg2 = ids.create(CommandType.TAKE); Receiver arg3 = ids.create(CommandType.TAKE); public PutForkCodeSegment(String pName, String rFork, String lFork) { arg1.setKey(pName); arg2.setKey(lFork); arg3.setKey(rFork); } @Override public void run() { Philosophy phil = arg1.asClass(Philosophy.class); Fork leftFork = arg2.asClass(Fork.class); Fork rightFork = arg3.asClass(Fork.class); System.out.println(phil.getName() +" put fork."); leftFork.onTheTable(phil.getName()); rightFork.onTheTable(phil.getName()); phil.setState(Philosophy.State.THINK); new ThinkCodeSegment(phil.getName()); ods.update("local", phil.getName(), phil); ods.update("local", leftFork.getForkName(), leftFork); ods.update("local", rightFork.getForkName(), rightFork); } }