async ValueTask FlushPage(Page page) { await InnerStorage.Write(page.PageNumber *_PagePool.PageSize, page.Content.Slice(page.WrittenStart, page.WrittenLength)); page.WrittenStart = 0; page.WrittenLength = 0; page.EnableEviction(); }
public Task <Result <bool> > IsSealedAsync(OperationContext context, CheckpointLogId logId) { if (FailureMode.HasFlag(FailureMode.Read)) { return(Task.FromResult(Result.FromErrorMessage <bool>("Persistent event storage failure"))); } return(InnerStorage.IsSealedAsync(context, logId)); }
protected override Task <BoolResult> ShutdownCoreAsync(OperationContext context) { if (InnerStorage != null) { return(InnerStorage.ShutdownAsync(context)); } return(BoolResult.SuccessTask); }
public Task <Result <Optional <ReadOnlyMemory <byte> > > > ReadAsync(OperationContext context, BlockReference cursor) { if (FailureMode.HasFlag(FailureMode.Read)) { return(Task.FromResult(Result.FromErrorMessage <Optional <ReadOnlyMemory <byte> > >("Volatile event storage failure"))); } return(InnerStorage.ReadAsync(context, cursor)); }
public async ValueTask DisposeAsync() { await Flush(); if (own) { await InnerStorage.DisposeAsync(); } Clear(false); pages.Clear(); }
public Task <BoolResult> GarbageCollectAsync(OperationContext context, CheckpointLogId logId) { if (FailureMode.HasFlag(FailureMode.SilentWrite)) { return(BoolResult.SuccessTask); } else if (FailureMode.HasFlag(FailureMode.Write)) { return(Task.FromResult(new BoolResult(errorMessage: "Persistent event storage failure"))); } return(InnerStorage.GarbageCollectAsync(context, logId)); }
public Task <BoolResult> AppendAsync(OperationContext context, BlockReference cursor, Stream stream) { if (FailureMode.HasFlag(FailureMode.SilentWrite)) { return(BoolResult.SuccessTask); } else if (FailureMode.HasFlag(FailureMode.Write)) { return(Task.FromResult(new BoolResult("Persistent event storage failure"))); } return(InnerStorage.AppendAsync(context, cursor, stream)); }
public Task <BoolResult> GarbageCollectAsync(OperationContext context, BlockReference cursor) { if (FailureMode.HasFlag(FailureMode.SilentWrite)) { return(BoolResult.SuccessTask); } else if (FailureMode.HasFlag(FailureMode.Write)) { return(Task.FromResult(new BoolResult("Volatile event storage failure"))); } return(InnerStorage.GarbageCollectAsync(context, cursor)); }
public Task <BoolResult> AppendAsync(OperationContext context, BlockReference cursor, ReadOnlyMemory <byte> piece) { if (FailureMode.HasFlag(FailureMode.SilentWrite)) { return(BoolResult.SuccessTask); } else if (FailureMode.HasFlag(FailureMode.Write)) { return(Task.FromResult(new BoolResult("Volatile event storage failure"))); } return(InnerStorage.AppendAsync(context, cursor, piece)); }
public static T Do <T>(T a, T b) { if (typeof(T) == typeof(Int16)) { return((T)(object)((Int16)(object)a + (Int16)(object)b)); } else if (typeof(T) == typeof(Int32)) { return((T)(object)((Int32)(object)a + (Int32)(object)b)); } else if (typeof(T) == typeof(Int64)) { return((T)(object)((Int64)(object)a + (Int64)(object)b)); } else if (typeof(T) == typeof(UInt16)) { return((T)(object)((UInt16)(object)a + (UInt16)(object)b)); } else if (typeof(T) == typeof(UInt32)) { return((T)(object)((UInt32)(object)a + (UInt32)(object)b)); } else if (typeof(T) == typeof(UInt64)) { return((T)(object)((UInt64)(object)a + (UInt64)(object)b)); } else if (typeof(T) == typeof(Single)) { return((T)(object)((Single)(object)a + (Single)(object)b)); } else if (typeof(T) == typeof(Double)) { return((T)(object)((Double)(object)a + (Double)(object)b)); } else if (typeof(T) == typeof(Byte)) { return((T)(object)(Byte)(Int32)(object)((Byte)(object)a + (Byte)(object)b)); } else if (typeof(T) == typeof(SByte)) { return((T)(object)(SByte)(Int32)(object)((SByte)(object)a + (SByte)(object)b)); } else if (typeof(T) == typeof(String)) { return((T)(object)String.Concat((string)(object)a, (string)(object)b)); } else { return(InnerStorage <T> .reflectionOperator(a, b)); } }
public async ValueTask Flush() { if (_LengthChanged) { await InnerStorage.Resize(Length); } foreach (var page in pages.Where(p => p.Value.Dirty)) { await FlushPage(page.Value); } await InnerStorage.Flush(); _LengthChanged = false; }
/// <summary> /// Make sure the underlying file can grow to write the data to commit /// </summary> /// <returns></returns> public async ValueTask ResizeInner() { await InnerStorage.Resize(Length); }