readGenerationSync method

  1. @override
int readGenerationSync()
inherited

Reads the stored compaction generation (0 if uninitialized), callable while holding withSharedLock or withExclusiveLock.

Implementation

@override
int readGenerationSync() {
  if (_holdMode == .none) {
    throw const WalPackLockException(
      'readGenerationSync must be called while holding lock',
    );
  }
  final raf = _slot.raf;
  if (raf == null) {
    return 0;
  }
  raf.setPositionSync(0);
  final read = raf.readIntoSync(_slot.genBuf);
  if (read < 8) {
    return 0;
  }
  final lo = _slot.genView.getUint32(0, .little);
  final hi = _slot.genView.getUint32(4, .little);
  return lo + hi * 4294967296;
}