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

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

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

Bytes.addressForRead介绍

暂无

代码示例

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

private static long readMessage(Bytes<?> bytes) {
  Jvm.safepoint();
  long start = bytes.readLong();
  if (true) {
    long rp = bytes.readPosition();
    long rl = bytes.readLimit();
    long addr = bytes.addressForRead(rp);
    long addrEnd = bytes.addressForRead(rl);
    Memory memory = OS.memory();
    for (addr += 8; addr + 7 < addrEnd; addr += 8)
      memory.readLong(addr);
  } else {
    while (bytes.readRemaining() > 7)
      bytes.readLong();
  }
  Jvm.safepoint();
  return start;
}

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

@NotNull
@Override
public final ExcerptTailer toStart() {
  assert direction != BACKWARD;
  final int firstCycle = queue.firstCycle();
  if (firstCycle == Integer.MAX_VALUE) {
    state = UNINITIALISED;
    return this;
  }
  if (firstCycle != this.cycle) {
    // moves to the expected cycle
    boolean found = cycle(firstCycle);
    assert found || store == null;
    if (found)
      state = FOUND_CYCLE;
  }
  index(queue.rollCycle().toIndex(cycle, 0));
  state = FOUND_CYCLE;
  if (wire() != null) {
    wire().bytes().readPosition(0);
    address = wire().bytes().addressForRead(0);
  }
  return this;
}

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

context.setStart(bytes.readPosition() - 4);
  readingDocumentFound = true;
  address = bytes.addressForRead(bytes.readPosition(), 4);
  Jvm.optionalSafepoint();
  return context;
} else {
  Bytes<?> bytes = context.wire().bytes();
  address = bytes.addressForRead(bytes.readPosition(), 4);

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

public void alignReadPosition(Bytes entry) {
  long positionAddr = entry.addressForRead(entry.readPosition());
  long skip = alignAddr(positionAddr, alignment) - positionAddr;
  if (skip > 0)
    entry.readSkip(skip);
}

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

private static long readMessage(Bytes<?> bytes) {
  Jvm.safepoint();
  long start = bytes.readLong();
  long rp = bytes.readPosition();
  long rl = bytes.readLimit();
  long addr = bytes.addressForRead(rp);
  long addrEnd = bytes.addressForRead(rl);
  Memory memory = OS.memory();
  for (addr += 8; addr + 7 < addrEnd; addr += 8)
    memory.readLong(addr);
  Jvm.safepoint();
  return start;
}

代码示例来源: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-queue

@NotNull
@Override
public final ExcerptTailer toStart() {
  assert direction != BACKWARD;
  final int firstCycle = queue.firstCycle();
  if (firstCycle == Integer.MAX_VALUE) {
    state = UNINITIALISED;
    return this;
  }
  if (firstCycle != this.cycle) {
    // moves to the expected cycle
    boolean found = cycle(firstCycle);
    assert found || store == null;
    if (found)
      state = FOUND_CYCLE;
  }
  index(queue.rollCycle().toIndex(cycle, 0));
  state = FOUND_CYCLE;
  if (wire() != null) {
    wire().bytes().readPosition(0);
    address = wire().bytes().addressForRead(0);
  }
  return this;
}

代码示例来源: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

context.setStart(bytes.readPosition() - 4);
  readingDocumentFound = true;
  address = bytes.addressForRead(bytes.readPosition(), 4);
  Jvm.optionalSafepoint();
  return context;
} else {
  Bytes<?> bytes = context.wire().bytes();
  address = bytes.addressForRead(bytes.readPosition(), 4);

相关文章

微信公众号

最新文章

更多