コード例 #1
0
ファイル: BasicPlane.java プロジェクト: roeematza/SSDPlayer
 public BasicPlane writeLP(int lp, int dummy) {
   List<BasicBlock> updatedBlocks = getNewBlocksList();
   int active = getActiveBlockIndex();
   if (active == -1) {
     active = getLowestEraseCleanBlockIndex();
     updatedBlocks.set(
         active, (BasicBlock) updatedBlocks.get(active).setStatus(BlockStatusGeneral.ACTIVE));
   }
   BasicBlock activeBlock = updatedBlocks.get(active);
   activeBlock = activeBlock.writeLP(lp);
   if (!activeBlock.hasRoomForWrite()) {
     activeBlock = (BasicBlock) activeBlock.setStatus(BlockStatusGeneral.USED);
   }
   updatedBlocks.set(active, activeBlock);
   Builder builder = getSelfBuilder();
   builder.setBlocks(updatedBlocks);
   return builder.build();
 }
コード例 #2
0
ファイル: BasicPlane.java プロジェクト: roeematza/SSDPlayer
  @Override
  protected Pair<BasicPlane, Integer> cleanPlane() {
    List<BasicBlock> cleanBlocks = getNewBlocksList();
    Pair<Integer, BasicBlock> pickedToClean = pickBlockToClean();
    int toMove = pickedToClean.getValue1().getValidCounter();
    int active = getActiveBlockIndex();
    BasicBlock activeBlock = cleanBlocks.get(active);

    for (BasicPage page : pickedToClean.getValue1().getPages()) {
      if (page.isValid()) {
        activeBlock = activeBlock.move(page.getLp());
      }
    }
    if (!activeBlock.hasRoomForWrite()) {
      activeBlock = (BasicBlock) activeBlock.setStatus(BlockStatusGeneral.USED);
    }
    cleanBlocks.set(active, activeBlock);
    cleanBlocks.set(pickedToClean.getValue0(), (BasicBlock) pickedToClean.getValue1().eraseBlock());
    Builder builder = getSelfBuilder();
    builder.setBlocks(cleanBlocks);
    return new Pair<>(builder.build(), toMove);
  }