public void addAll(CompositeQueue tempCommandQueue) { foreach (int key in tempCommandQueue.getMap().Keys) { Command modelCommand = tempCommandQueue.getMap()[key]; insertMessage(key, modelCommand); } }
public CommandQueue() { currentVersion=0; set=new HashSet<Int32>(); commandQueue=new CompositeQueue(); tempCommandQueue =new CompositeQueue(); timer=new Timer(); mode=Mode.normal; }
public int toMode(Mode mode) { try{ reentrantLock.enter(); if(mode.Equals(Mode.image)){ this.mode=Mode.locking; while(commandQueue.isNotEmpty()){ Zzz.zzz(100); } this.mode=Mode.image; log.info("ready for image command queue is locked current version is " +currentVersion); }else{ lock (this){ this.mode=Mode.normal; commandQueue.addAll(tempCommandQueue); tempCommandQueue =new CompositeQueue(); System.Threading.Monitor.Pulse(this); log.info("releasing queue current version is " +currentVersion); } } return currentVersion; }finally { reentrantLock.exit(); } }