readGenerationStateSync method
Reads both committed and pending generations while holding a lock.
Implementation
@override
({int committed, int pending}) readGenerationStateSync() {
if (_holdMode == .none) {
throw const WalPackLockException(
'readGenerationStateSync must be called while holding lock',
);
}
final raf = _slot.raf;
if (raf == null) {
return (committed: 0, pending: 0);
}
raf.setPositionSync(0);
final read = raf.readIntoSync(_slot.genBuf);
if (read < 8) {
return (committed: 0, pending: 0);
}
final cLo = _slot.genView.getUint32(0, .little);
final cHi = _slot.genView.getUint32(4, .little);
final committed = cLo + cHi * 4294967296;
if (read < 16) {
return (committed: committed, pending: committed);
}
final pLo = _slot.genView.getUint32(8, .little);
final pHi = _slot.genView.getUint32(12, .little);
final pending = pLo + pHi * 4294967296;
return (committed: committed, pending: pending);
}