/**
   * Dequeues all previously enqueued wrappers and writes them to the stream.
   *
   * @throws IOException If failed.
   */
  void delayedWrite() throws IOException {
    if (wrappers != null)
      for (GridOptimizedWrapper w = wrappers.poll(); w != null; w = wrappers.poll())
        w.delayedWriteExternal(this);

    wrappers = null; // GC.
  }
  /**
   * Adds a wrapper for delayed processing.
   *
   * @param wrapper Wrapper to add.
   */
  void delay(GridOptimizedWrapper wrapper) {
    if (wrappers == null) wrappers = new LinkedList<GridOptimizedWrapper>();

    // Add to FIFO queue.
    wrappers.offer(wrapper);
  }