コード例 #1
0
  private Operation optimizeSets() {
    // make sure there are at least two get operations in a row before
    // attempting to optimize them.
    Operation optimizedOp = writeQ.remove();
    if (writeQ.peek() instanceof CASOperation) {
      OptimizedSetImpl og = new OptimizedSetImpl((CASOperation) optimizedOp);
      optimizedOp = og;

      while (writeQ.peek() instanceof StoreOperation
          && og.size() < MAX_SET_OPTIMIZATION_COUNT
          && og.bytes() < MAX_SET_OPTIMIZATION_BYTES) {
        CASOperation o = (CASOperation) writeQ.remove();
        if (!o.isCancelled()) {
          og.addOperation(o);
        }
      }

      // Initialize the new mega set
      optimizedOp.initialize();
      assert optimizedOp.getState() == OperationState.WRITING;
    }

    return optimizedOp;
  }
コード例 #2
0
 /** Construct an optimized get starting with the given get operation. */
 public OptimizedSetImpl(CASOperation firstStore) {
   super(-1, -1, NOOP_CALLBACK);
   addOperation(firstStore);
 }