slumberdb/slumberdb-service-model/src/main/java/org/boon/slumberdb/stores/log/CollectorManager.java
private void manageInputWriterChannel() throws InterruptedException {


        try {

            ByteBuffer dataToWriteToFile;
            dataToWriteToFile = inputChannel.poll();  //no wait

            //If it is null, it means the inputChannel is empty and we need to flush.
            if (dataToWriteToFile == null) {
                queueEmptyMaybeFlush();
                dataToWriteToFile = inputChannel.poll();
            }


            //If it is still null, this means that we need to wait
            //for more items to show up in the inputChannel.
            if (dataToWriteToFile == null) {
                dataToWriteToFile = waitForNextDataToWrite();
            }

            //We have to check for null again because we could have been interrupted.
            if (dataToWriteToFile != null) {
                //Write it
                writer.nextBufferToWrite(dataToWriteToFile);
                //Then give it back
                if (RECYCLE_BUFFER) {
                    recycleChannel.offer(dataToWriteToFile);
                }

            }

        } catch (InterruptedException ex) {
            throw ex;
        } catch (Exception ex) {
            ex.printStackTrace();
            ex.printStackTrace(System.err);
        }

    }
private void manageInputWriterChannel() throws InterruptedException {


        try {

            ByteBuffer dataToWriteToFile;
            dataToWriteToFile = inputChannel.poll();  //no wait

            //If it is null, it means the inputChannel is empty and we need to flush.
            if (dataToWriteToFile == null) {
                queueEmptyMaybeFlush();
                dataToWriteToFile = inputChannel.poll();
            }


            //If it is still null, this means that we need to wait
            //for more items to show up in the inputChannel.
            if (dataToWriteToFile == null) {
                dataToWriteToFile = waitForNextDataToWrite();
            }

            //We have to check for null again because we could have been interrupted.
            if (dataToWriteToFile != null) {
                //Write it
                writer.nextBufferToWrite(dataToWriteToFile);
                //Then give it back
                if (RECYCLE_BUFFER) {
                    recycleChannel.offer(dataToWriteToFile);
                }

            }

        } catch (InterruptedException ex) {
            throw ex;
        } catch (Exception ex) {
            ex.printStackTrace();
            ex.printStackTrace(System.err);
        }

    }
Queue and batch writer main logic.
This is where the magic happens.

@throws InterruptedException