docs: public int appendTask(long sourceHSId, TransactionInfoBaseMessage task) throws IOException {
          Preconditions.checkState(compiledSize == 0, "buffer is already compiled");
  
          final int msgSerializedSize = task.getSerializedSize();
          ensureCapacity(taskHeaderSize() + msgSerializedSize);
  
          ByteBuffer bb = m_container.b();
          bb.putInt(msgSerializedSize);
          bb.putLong(sourceHSId);
  
          int limit = bb.limit();
          bb.limit(bb.position() + msgSerializedSize);
          task.flattenToBuffer(bb.slice());
          bb.limit(limit);
          bb.position(bb.position() + msgSerializedSize);
  
          // Don't allow any further expansion to the underlying buffer
          if (bb.position() + taskHeaderSize() > DEFAULT_BUFFER_SIZE) {
              compile();
              return 0;
          } else {
              return DEFAULT_BUFFER_SIZE - (bb.position() + taskHeaderSize());
          }
      }