net.openhft.chronicle.bytes.Bytes.writeSkip()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中net.openhft.chronicle.bytes.Bytes.writeSkip()方法的一些代码示例,展示了Bytes.writeSkip()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.writeSkip()方法的具体详情如下:
包路径:net.openhft.chronicle.bytes.Bytes
类名称:Bytes
方法名:writeSkip

Bytes.writeSkip介绍

暂无

代码示例

代码示例来源:origin: OpenHFT/Chronicle-Queue

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);

代码示例来源:origin: OpenHFT/Chronicle-Queue

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());
  }
}

代码示例来源:origin: OpenHFT/Chronicle-Queue

@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();
  }
}

代码示例来源:origin: net.openhft/chronicle-bytes

/**
 * 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);
}

代码示例来源:origin: net.openhft/chronicle-bytes

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);
}

代码示例来源:origin: net.openhft/chronicle-bytes

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);
}

代码示例来源:origin: net.openhft/chronicle-queue

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());
  }
}

代码示例来源:origin: net.openhft/chronicle-queue

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);

代码示例来源:origin: net.openhft/chronicle-map

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();
}

代码示例来源:origin: net.openhft/chronicle-map

destination.writeSkip(key.size());
valueSizeMarshaller.writeSize(destination, value.size());
value.writeTo(destination, destination.writePosition());
destination.writeSkip(value.size());

代码示例来源:origin: net.openhft/chronicle-map

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();
  
}

代码示例来源:origin: net.openhft/chronicle-map

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();
  
}

代码示例来源:origin: net.openhft/chronicle-map

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();
  
}

代码示例来源:origin: net.openhft/chronicle-map

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();
  
}

代码示例来源:origin: net.openhft/chronicle-queue

@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();
  }
}

相关文章

微信公众号

最新文章

更多