class PersistentMessageBuffer implements MessageBuffer {

    @Override
    public void close() throws IOException {
        Cursor[] copyOfWaitingCursors;
        synchronized (this) {
            if (!isOpen()) return;
            if (syncTask != null) {
                syncTask.cancel();
                syncTask = null;
            }
            if (current != null) {
                current.close();
                current = null;
            }
            open = false;
            copyOfWaitingCursors = waitingCursors;
        }

        // interrupt threads waiting for messages
        for (Cursor c : copyOfWaitingCursors) {
            if (c != null) c.interrupt();
        }
    }

    public  PersistentMessageBuffer(File dir);

}