bytes.writeSkip(4); final String debugMessage = "!! Skipped due to recovery of locked header !! By thread " + Thread.currentThread().getName() + ", pid " + OS.getProcessId(); if (bytes.compareAndSwapInt(offset, num, emptyMetaData)) { warn().on(getClass(), msgStart + " switching to a corrupt meta data message"); bytes.writeSkip(sizeToSkip + 4); } else { int num2 = bytes.readVolatileInt(offset);
private static void writeMessage(Wire wire, int messageSize) { Bytes<?> bytes = wire.bytes(); long wp = bytes.writePosition(); // TODO Optimise wire to give similar performance. if (false) { for (int i = 0; i < messageSize; i += 8) bytes.writeLong(0L); } else { long addr = bytes.addressForWrite(wp); Memory memory = OS.memory(); for (int i = 0; i < messageSize; i += 16) { memory.writeLong(addr + i, 0L); memory.writeLong(addr + i + 8, 0L); } bytes.writeSkip(messageSize); } bytes.writeLong(wp, System.nanoTime()); } }
@Override public void writeBytes(@NotNull BytesStore bytes) throws UnrecoverableTimeoutException { writeLock.lock(); try { int cycle = queue.cycle(); if (this.cycle != cycle || wire == null) rollCycleTo(cycle); position(writeHeader(wire, (int) queue.overlapSize())); assert ((AbstractWire) wire).isInsideHeader(); beforeAppend(wire, wire.headerNumber() + 1); Bytes<?> wireBytes = wire.bytes(); wireBytes.write(bytes); if (padToCacheLines == Padding.WORD) wireBytes.writeSkip((-wireBytes.writePosition()) & 0x3); wire.updateHeader(position, false, 0); lastIndex(wire.headerNumber()); lastPosition = position; lastCycle = cycle; store.writePosition(position); writeIndexForPosition(lastIndex, position); } catch (StreamCorruptedException e) { throw new AssertionError(e); } finally { writeLock.unlock(); } }
/** * will unwrite from the offset upto the current write position of the destination bytes * * @param fromOffset the offset from the target byytes * @param count the number of bytes to un-write */ default void unwrite(long fromOffset, int count) { long wp = writePosition(); if (wp < fromOffset) return; write(fromOffset, this, fromOffset + count, wp - fromOffset); writeSkip(-count); }
public static void lazyWrite(@NotNull Bytes bytes, long capacity) throws BufferOverflowException { assert (bytes.writePosition() & 0x7) == 0; bytes.writeLong(capacity); bytes.writeLong(0L); // used bytes.writeSkip(capacity << 3); }
public static void write(@NotNull Bytes bytes, long capacity) throws BufferOverflowException, IllegalArgumentException { assert (bytes.writePosition() & 0x7) == 0; bytes.writeLong(capacity); bytes.writeLong(0L); // used long start = bytes.writePosition(); bytes.zeroOut(start, start + (capacity << 3)); bytes.writeSkip(capacity << 3); }
private static void writeMessage(Wire wire, int messageSize) { Bytes<?> bytes = wire.bytes(); long wp = bytes.writePosition(); long addr = bytes.addressForWrite(wp); Memory memory = OS.memory(); for (int i = 0; i < messageSize; i += 16) { memory.writeLong(addr + i, 0L); memory.writeLong(addr + i + 8, 0L); } bytes.writeSkip(messageSize); bytes.writeLong(wp, System.nanoTime()); } }
bytes.writeSkip(4); final String debugMessage = "!! Skipped due to recovery of locked header !! By thread " + Thread.currentThread().getName() + ", pid " + OS.getProcessId(); if (bytes.compareAndSwapInt(offset, num, emptyMetaData)) { warn().on(getClass(), msgStart + " switching to a corrupt meta data message"); bytes.writeSkip(sizeToSkip + 4); } else { int num2 = bytes.readVolatileInt(offset);
void initValueSize(long valueSize) { this.valueSize = valueSize; Bytes segmentBytes = s.segmentBytesForWrite(); segmentBytes.writePosition(valueSizeOffset); mh.m().valueSizeMarshaller.writeSize(segmentBytes, valueSize); long currentPosition = segmentBytes.writePosition(); long currentAddr = segmentBytes.addressForRead(currentPosition); long skip = alignAddr(currentAddr, mh.m().alignment) - currentAddr; if (skip > 0) segmentBytes.writeSkip(skip); valueOffset = segmentBytes.writePosition(); }
void initValueSize(long valueSize) { boolean wasValueSizeInit = this.valueSizeInit(); this.valueSize = valueSize; Bytes segmentBytes = this.segmentBytesForWriteGuarded(); segmentBytes.writePosition(valueSizeOffset()); this.m().valueSizeMarshaller.writeSize(segmentBytes, valueSize); long currentPosition = segmentBytes.writePosition(); long currentAddr = segmentBytes.addressForRead(currentPosition); long skip = (VanillaChronicleMap.alignAddr(currentAddr, this.m().alignment)) - currentAddr; if (skip > 0) segmentBytes.writeSkip(skip); valueOffset = segmentBytes.writePosition(); if (wasValueSizeInit) this.closeValueSizeDependants(); }
void initValueSize(long valueSize) { boolean wasValueSizeInit = this.valueSizeInit(); this.valueSize = valueSize; Bytes segmentBytes = this.segmentBytesForWriteGuarded(); segmentBytes.writePosition(valueSizeOffset()); this.m().valueSizeMarshaller.writeSize(segmentBytes, valueSize); long currentPosition = segmentBytes.writePosition(); long currentAddr = segmentBytes.addressForRead(currentPosition); long skip = (VanillaChronicleMap.alignAddr(currentAddr, this.m().alignment)) - currentAddr; if (skip > 0) segmentBytes.writeSkip(skip); valueOffset = segmentBytes.writePosition(); if (wasValueSizeInit) this.closeValueSizeDependants(); }
void initValueSize(long valueSize) { boolean wasValueSizeInit = this.valueSizeInit(); this.valueSize = valueSize; Bytes segmentBytes = this.segmentBytesForWriteGuarded(); segmentBytes.writePosition(valueSizeOffset()); this.m().valueSizeMarshaller.writeSize(segmentBytes, valueSize); long currentPosition = segmentBytes.writePosition(); long currentAddr = segmentBytes.addressForRead(currentPosition); long skip = (VanillaChronicleMap.alignAddr(currentAddr, this.m().alignment)) - currentAddr; if (skip > 0) segmentBytes.writeSkip(skip); valueOffset = segmentBytes.writePosition(); if (wasValueSizeInit) this.closeValueSizeDependants(); }
void initValueSize(long valueSize) { boolean wasValueSizeInit = this.valueSizeInit(); this.valueSize = valueSize; Bytes segmentBytes = this.segmentBytesForWriteGuarded(); segmentBytes.writePosition(valueSizeOffset()); this.m().valueSizeMarshaller.writeSize(segmentBytes, valueSize); long currentPosition = segmentBytes.writePosition(); long currentAddr = segmentBytes.addressForRead(currentPosition); long skip = (VanillaChronicleMap.alignAddr(currentAddr, this.m().alignment)) - currentAddr; if (skip > 0) segmentBytes.writeSkip(skip); valueOffset = segmentBytes.writePosition(); if (wasValueSizeInit) this.closeValueSizeDependants(); }
@Override public void writeBytes(@NotNull BytesStore bytes) throws UnrecoverableTimeoutException { writeLock.lock(); try { int cycle = queue.cycle(); if (wire == null) setWireIfNull(cycle); if (this.cycle != cycle) rollCycleTo(cycle); position(writeHeader(wire, (int) queue.overlapSize())); assert ((AbstractWire) wire).isInsideHeader(); beforeAppend(wire, wire.headerNumber() + 1); Bytes<?> wireBytes = wire.bytes(); wireBytes.write(bytes); if (padToCacheLines == Padding.WORD) wireBytes.writeSkip((-wireBytes.writePosition()) & 0x3); wire.updateHeader(position, false, 0); lastIndex(wire.headerNumber()); lastPosition = position; lastCycle = cycle; store.writePosition(position); writeIndexForPosition(lastIndex, position); } catch (StreamCorruptedException e) { throw new AssertionError(e); } finally { writeLock.unlock(); } }