public void destroy() {
        synchronized (buffers) {
            destroyed = true;

            buffers.clear();
            buffers.notifyAll();
        }
    }
@Test
    void testDestroy() throws Exception {
        BatchShuffleReadBufferPool bufferPool = createBufferPool();
        List<MemorySegment> buffers = bufferPool.requestBuffers();
        bufferPool.recycle(buffers);

        assertThat(bufferPool.isDestroyed()).isFalse();
        assertThat(bufferPool.getAvailableBuffers()).isEqualTo(bufferPool.getNumTotalBuffers());

        buffers = bufferPool.requestBuffers();
        assertThat(bufferPool.getAvailableBuffers())
                .isEqualTo(bufferPool.getNumTotalBuffers() - buffers.size());

        bufferPool.destroy();
        assertThat(bufferPool.isDestroyed()).isTrue();
        assertThat(bufferPool.getAvailableBuffers()).isZero();
    }