boolean tryAddEvent(byte[] event)
  {
    while (true) {
      long state = getState();
      if (isSealed(state)) {
        return false;
      }
      int bufferWatermark = bufferWatermark(state);
      if (bufferWatermark == 0) {
        if (tryAddFirstEvent(event)) {
          return true;
        }
      } else if (newBufferWatermark(bufferWatermark, event) <= emitter.maxBufferWatermark) {
        if (tryAddNonFirstEvent(state, event)) {
          return true;
        }
      } else {
        seal();
        return false;
      }
    }
  }
boolean tryAddEvent ( byte [ ] event ) { while ( true ) { long state = getState ( ) ; if ( isSealed ( state ) ) { return false ; } int bufferWatermark = bufferWatermark ( state ) ; if ( bufferWatermark == 0 ) { if ( tryAddFirstEvent ( event ) ) { return true ; } } else if ( newBufferWatermark ( bufferWatermark , event ) <= emitter . maxBufferWatermark ) { if ( tryAddNonFirstEvent ( state , event ) ) { return true ; } } else { seal ( ) ; return false ; } } }
Tries to add (write) event to the batch, returns true, if successful. If fails, no subsequent attempts to add event
to this batch will succeed, the next batch should be taken.