docs: protected synchronized boolean cancel(Object x) {
          // First check the expedited buffer
          synchronized (lock) {
              if (expeditedPutIndex > expeditedTakeIndex) {
                  for (int i = expeditedTakeIndex; i < expeditedPutIndex; i++) {
                      if (expeditedBuffer[i] == x) {
                          System.arraycopy(expeditedBuffer, i + 1, expeditedBuffer, i, expeditedPutIndex - i - 1);
                          expeditedPutIndex--;
                          expeditedBuffer[expeditedPutIndex] = null;
                          numberOfUsedExpeditedSlots.getAndDecrement(); // D615053
                          return true;
                      }
                  }
              } else if (expeditedPutIndex != expeditedTakeIndex || expeditedBuffer[expeditedTakeIndex] != null) {
                  for (int i = expeditedTakeIndex; i < buffer.length; i++) {
                      if (expeditedBuffer[i] == x) {
                          if (i != expeditedBuffer.length - 1) {
                              System.arraycopy(expeditedBuffer, i + 1, expeditedBuffer, i, expeditedBuffer.length - i - 1);
                          }
  
                          if (expeditedPutIndex != 0) {
                              expeditedBuffer[expeditedBuffer.length - 1] = expeditedBuffer[0];
                              System.arraycopy(expeditedBuffer, 1, expeditedBuffer, 0, expeditedPutIndex - 1);
                              expeditedPutIndex--;
                          } else {
                              expeditedPutIndex = expeditedBuffer.length - 1;
                          }
  
                          expeditedBuffer[expeditedPutIndex] = null;
                          numberOfUsedExpeditedSlots.getAndDecrement(); // D615053
                          return true;
                      }
                  }
  
                  // D610567 - Scan first section of expedited BoundedBuffer
                  for (int i = 0; i < expeditedPutIndex; i++) {
                      if (expeditedBuffer[i] == x) {
                          System.arraycopy(expeditedBuffer, i + 1, expeditedBuffer, i, expeditedPutIndex - i - 1);
                          expeditedPutIndex--;
                          expeditedBuffer[expeditedPutIndex] = null;
                          numberOfUsedExpeditedSlots.getAndDecrement(); // D615053
                          return true;
                      }
                  }
  
              }
              // Next check the main buffer
              if (putIndex > takeIndex) {
                  for (int i = takeIndex; i < putIndex; i++) {
                      if (buffer[i] == x) {
                          System.arraycopy(buffer, i + 1, buffer, i, putIndex - i - 1);
                          putIndex--;
                          buffer[putIndex] = null;
                          numberOfUsedSlots.getAndDecrement(); // D615053
                          return true;
                      }
                  }
              } else if (putIndex != takeIndex || buffer[takeIndex] != null) {
                  for (int i = takeIndex; i < buffer.length; i++) {
                      if (buffer[i] == x) {
                          if (i != buffer.length - 1) {
                              System.arraycopy(buffer, i + 1, buffer, i, buffer.length - i - 1);
                          }
  
                          if (putIndex != 0) {
                              buffer[buffer.length - 1] = buffer[0];
                              System.arraycopy(buffer, 1, buffer, 0, putIndex - 1);
                              putIndex--;
                          } else {
                              putIndex = buffer.length - 1;
                          }
  
                          buffer[putIndex] = null;
                          numberOfUsedSlots.getAndDecrement(); // D615053
                          return true;
                      }
                  }
  
                  // D610567 - Scan first section of BoundedBuffer
                  for (int i = 0; i < putIndex; i++) {
                      if (buffer[i] == x) {
                          System.arraycopy(buffer, i + 1, buffer, i, putIndex - i - 1);
                          putIndex--;
                          buffer[putIndex] = null;
                          numberOfUsedSlots.getAndDecrement(); // D615053
                          return true;
                      }
                  }
  
              }
          }
  
          return false;
      }