internal long AcquirePackerLock(long prolongExisting = 0) { if (AdditionalCorrectnessChecks.Enabled) { AssertValidPointer(); } var existing = (Timestamp)Unsafe.ReadUnaligned <long>(_statePointer + StreamLogStateRecord.PackerTimestampOffset); var now = ProcessConfig.CurrentTime; if (prolongExisting == 0 && (now - existing).TimeSpan < TimeSpan.FromSeconds(StartupConfig.PackerTimeoutSeconds)) { return(0); } var comparand = prolongExisting == 0 ? (long)existing : prolongExisting; var existing1 = Interlocked.CompareExchange( ref *(long *)(_statePointer + StreamLogStateRecord.PackerTimestampOffset), (long)now, comparand); if (existing1 == comparand) { return((long)now); } return(0); }
/// <summary> /// Sets the pixel buffer in an unsafe manor this should not be used unless you know what its doing!!! /// </summary> /// <param name="pixels">The pixel buffer</param> /// <param name="ownedBuffer">if set to <c>true</c> then this instance ownes the buffer and thus should dispose of it afterwards.</param> private void SetPixelBufferUnsafe(Buffer2D <TPixel> pixels, bool ownedBuffer) { this.PixelBuffer = pixels; this.ownedBuffer = ownedBuffer; this.Width = pixels.Width; this.Height = pixels.Height; this.PixelSize = Unsafe.SizeOf <TPixel>(); this.RowStride = this.Width * this.PixelSize; }
internal static ref T NullRef <T>() => ref SupposedlyUnsafe.AsRef <T>(null);
public static bool IsNullRef <T>(ref T source) => SupposedlyUnsafe.AsPointer(ref source) is null;