code: public long appendEntry(JournalEntry entry) {
      // TODO(gpang): handle bounding the queue if it becomes too large.
  
      /**
       * Protocol for appending entries
       *
       * This protocol is lock free, to reduce the overhead in critical sections. It uses
       * {@link AtomicLong} and {@link ConcurrentLinkedQueue} which are both lock-free.
       *
       * The invariant that must be satisfied is that the 'counter' that is returned must be
       * greater than or equal to the actual counter of the entry in the queue.
       *
       * In order to guarantee the invariant, the {@link #mCounter} is incremented before adding the
       * entry to the {@link #mQueue}. AFTER the counter is incremented, whenever the counter is
       * read, it is guaranteed to be greater than or equal to the counter for the queue entries.
       *
       * Therefore, the {@link #mCounter} must be read AFTER the entry is added to the queue. The
       * resulting read of the counter AFTER the entry is added is guaranteed to be greater than or
       * equal to the counter for the entries in the queue.
       */
      mCounter.incrementAndGet();
      mQueue.offer(entry);
      return mCounter.get();
    }
docs: Appends a {@link JournalEntry} for writing to the journal.
  
  @param entry the {@link JournalEntry} to append
  @return a counter for the entry, for flushing