示例#1
0
 public static void writeDataOnce(
     @NotNull WireOut wireOut, boolean metaData, @NotNull WriteMarshallable writer) {
   Bytes bytes = wireOut.bytes();
   long position = bytes.writePosition();
   int metaDataBit = metaData ? Wires.META_DATA : 0;
   int value = metaDataBit | Wires.NOT_READY | Wires.UNKNOWN_LENGTH;
   if (!bytes.compareAndSwapInt(position, 0, value)) return;
   bytes.writeSkip(4);
   writer.writeMarshallable(wireOut);
   int length =
       metaDataBit
           | toIntU30(
               bytes.writePosition() - position - 4,
               "Document length %,d out of 30-bit int range.");
   if (!bytes.compareAndSwapInt(position, value, length | Wires.META_DATA))
     throw new AssertionError();
 }
示例#2
0
 public static void writeData(
     @NotNull WireOut wireOut,
     boolean metaData,
     boolean notReady,
     @NotNull WriteMarshallable writer) {
   Bytes bytes = wireOut.bytes();
   long position = bytes.writePosition();
   int metaDataBit = metaData ? Wires.META_DATA : 0;
   bytes.writeOrderedInt(metaDataBit | Wires.NOT_READY | Wires.UNKNOWN_LENGTH);
   writer.writeMarshallable(wireOut);
   int length =
       metaDataBit
           | toIntU30(
               bytes.writePosition() - position - 4,
               "Document length %,d out of 30-bit int range.");
   bytes.writeOrderedInt(position, length | (notReady ? Wires.NOT_READY : 0));
 }