class PersistentMessageBuffer implements MessageBuffer {

    public void cleanup() throws IOException {
        for (;;) {
            File doomed;
            synchronized (this) {
                if (maxSize == 0 || getSize() <= maxSize || firstFile >= lastFile - 1) return;
                doomed = getFile(firstFile);
                ++firstFile;
                // todo what about cursors that might have doomed open?
            }
            if (!doomed.delete()) {
                throw new IOException("Unable to delete [" + doomed + "]");
            }
        }
    }

    public  PersistentMessageBuffer(File dir);

}