public void Reset() { lock (this.syncRoot) { if (this.state == State.Disposed) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ObjectDisposed()); } if (this.current != null) { this.current.Detach(); this.current = null; } if ((this.readContext != null) && (!this.readContext.IsInvalid)) { this.readContext.Close(); this.readContext = null; } this.state = State.BeforeFirst; } }
bool ReadLogRecord() { if (!((this.readContext == null || this.readContext.IsInvalid) && (this.current == null))) { // An internal consistency check has failed. The indicates a bug in IO.Log's internal processing // Rather than proceeding with non-deterministic execution and risking the loss or corruption of // log records, we failfast the process. DiagnosticUtility.FailFast("Should only call this for first record!"); } unsafe { byte *readBuffer; int bufferLength; byte recordType; ulong lsnUser; ulong lsnPrevious; if (!UnsafeNativeMethods.ReadLogRecordSync( this.recordSequence.MarshalContext, ref this.startLsn, this.mode, out readBuffer, out bufferLength, out recordType, out lsnUser, out lsnPrevious, out this.readContext)) { this.state = State.AfterLast; return(false); } if ((recordType & Const.ClfsDataRecord) != 0) { this.current = new LogLogRecord( new SequenceNumber(this.startLsn), new SequenceNumber(lsnUser), new SequenceNumber(lsnPrevious), readBuffer, bufferLength); this.state = State.Valid; return(true); } else { return(ReadNextLogRecord()); } } }
public void Dispose() { lock (this.syncRoot) { if (this.current != null) { this.current.Detach(); this.current = null; } if ((this.readContext != null) && (!this.readContext.IsInvalid)) { this.readContext.Close(); } this.state = State.Disposed; } }
bool ReadRestartArea() { if (!((this.readContext == null || this.readContext.IsInvalid) && (this.current == null))) { // An internal consistency check has failed. The indicates a bug in IO.Log's internal processing // Rather than proceeding with non-deterministic execution and risking the loss or corruption of // log records, we failfast the process. DiagnosticUtility.FailFast("Should only call this for first record!"); } unsafe { byte *readBuffer; int bufferLength; ulong lsnRecord; if (!UnsafeNativeMethods.ReadLogRestartAreaSync( this.recordSequence.MarshalContext, out readBuffer, out bufferLength, out lsnRecord, out this.readContext)) { this.state = State.AfterLast; return(false); } this.current = new LogLogRecord( new SequenceNumber(lsnRecord), SequenceNumber.Invalid, SequenceNumber.Invalid, readBuffer, bufferLength); this.state = State.Valid; return(true); } }