Package freenet.support

Examples of freenet.support.RandomGrabArray$Block


    }

    private ArrayList<Block> getBlocksAroundBlockByState(int column, int row, BlockState blockState){
        ArrayList<Block> blocksWithBlockState = new ArrayList<Block>();
        for(Direction direction : Direction.values()){
            Block block = getBlockFromDirection(column, row, direction);
            if(block!=null && block.getBlockState()!=null && block.getBlockState()== blockState)
                blocksWithBlockState.add(block);
        }
        return blocksWithBlockState;
    }
View Full Code Here


    private void generateBlocks(int columns, int rows) {
        blocks = new Block[columns][rows];
        for(int c=0; c<columns; c++)
            for(int r=0; r<rows; r++)
                blocks[c][r] = new Block(c*blockSize, r*blockSize, blockSize, blockSize);
    }
View Full Code Here

                else
                    g.drawImage(emptyFieldImage, 0, 0,null);

                for(int c=0; c<mineSweeper.getBlocks().length; c++)
                    for(int r=0; r<mineSweeper.getBlocks()[0].length; r++) {
                        Block block = mineSweeper.getBlocks()[c][r];

                        if(block.getBlockNumber()!=null){
                            g.setColor(block.getBlockNumber().getColor());
                            g.drawString(""+block.getBlockNumber().getNumber(), block.x+4, block.y+12);
                        }
                        if(block.getBlockState()!=null)
                            switch(block.getBlockState()){
                                case FLAG:      g.drawImage(flagBlock, block.x, block.y, null);
                                    break;
                                case BOMB:      g.drawImage(bombBlock, block.x, block.y, null);
                                    break;
                                case EMPTY:     if(block.getBlockNumber()==null)
                                    g.drawImage(emptyBlock, block.x, block.y, null);
                            }
                    }

            }
View Full Code Here

    return parentGrabArray;
  }
 
  /** Grab it to avoid race condition when unregistering twice in parallel. */
  private synchronized RandomGrabArray grabParentGrabArray() {
    RandomGrabArray ret = parentGrabArray;
    parentGrabArray = null;
    return ret;
  }
View Full Code Here

   * @param oldPrio If we are changing priorities it can matter what the old priority is.
   * However the parent method, SendableRequest, ignores this. In any case,
   * (short)-1 means not specified (look it up).
   */
  public void unregister(ClientContext context, short oldPrio) {
    RandomGrabArray arr = grabParentGrabArray();
    if(arr != null) {
      synchronized(getScheduler(context)) {
        arr.remove(this, context);
      }
    } else {
      // Should this be a higher priority?
      if(logMINOR)
        Logger.minor(this, "Cannot unregister "+this+" : not registered", new Exception("debug"));
View Full Code Here

    return super.toString();
  }
 
    @Override
    public boolean reduceWakeupTime(long wakeupTime, ClientContext context) {
        RandomGrabArray parent = getParentGrabArray();
        if(parent == null) return false;
        return parent.reduceWakeupTime(wakeupTime, context);
    }
View Full Code Here

        return parent.reduceWakeupTime(wakeupTime, context);
    }

    @Override
    public void clearWakeupTime(ClientContext context) {
        RandomGrabArray parent = getParentGrabArray();
        if(parent == null) return;
        parent.clearWakeupTime(context);
    }
View Full Code Here

          // maybe we should ask people to report that error if seen
          Logger.normal(this, "In wrong priority class: "+req+" (req.prio="+req.getPriorityClass()+" but chosen="+choosenPriorityClass+ ')');
          // Remove it.
          ClientRequestRGANode clientGrabber = chosenTracker.getGrabber(req.getClient());
          if(clientGrabber != null) {
            RandomGrabArray baseRGA = clientGrabber.getGrabber(req.getSchedulerGroup());
            if(baseRGA != null) {
              // Must synchronize to avoid nasty race conditions with cooldown.
              synchronized(this) {
                baseRGA.remove(req, context);
              }
            } else {
              // Okay, it's been removed already. Cool.
            }
          } else {
View Full Code Here

                        ClientRequestRGANode requestGrabber = prio.getGrabber(client);
                        System.out.println("SRGA for client: "+requestGrabber);
                        for(int l=0;l<requestGrabber.size();l++) {
                            ClientRequestSchedulerGroup cr = requestGrabber.getClient(l);
                            System.out.println("Request "+l+" : "+cr);
                            RandomGrabArray rga = requestGrabber.getGrabber(cr);
                            System.out.println("Queued SendableRequests: "+rga.size()+" on "+rga);
                            long sendable = 0;
                            long all = 0;
                            for(int m=0;m<rga.size();m++) {
                                SendableRequest req = (SendableRequest) rga.get(m);
                                if(req == null) continue;
                                sendable += req.countSendableKeys(context);
                                all += req.countAllKeys(context);
                            }
                            System.out.println("Sendable keys: "+sendable+" all keys "+all+" diff "+(all-sendable));
View Full Code Here

    } else return entityHeight;
  }

  @Override
  public AlmostBoolean isBlockSolid(final int id) {
    final Block block = Block.byId[id];
    if (block == null || block.material == null) return AlmostBoolean.MAYBE;
    else return AlmostBoolean.match(block.material.isSolid());
  }
View Full Code Here

TOP

Related Classes of freenet.support.RandomGrabArray$Block

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.