private fun tryQueueCurrentBuffer(elapsedWaiting: Long): Boolean { if (currentBuffer.isEmpty()) return true return if (isOpen && neverPubQueue.size() < neverPubCapacity) { neverPubQueue.add(currentBuffer) totalQueuedRecords.addAndGet(currentBuffer.sizeRecords()) totalQueuedBuffers.incrementAndGet() onQueueBufferSuccess(currentBuffer, elapsedWaiting) currentBuffer = RecordBuffer(flow) true } else if (elapsedWaiting > 0) { onQueueBufferTimeout(currentBuffer, elapsedWaiting) false } else false }
Keep private . Call only when holding lock .