예제 #1
0
            private protected async ValueTask ConsumeAsync()
            {
                await reader.ReadBlockAsync(metadataBuffer.AsMemory()).ConfigureAwait(false);

                metadata = new LogEntryMetadata(metadataBuffer);
                consumed = false;
            }
예제 #2
0
            // slow path - consume metadata asynchronously and allocate buffer on the heap
            private async ValueTask ConsumeSlowAsync()
            {
                if (metadataBuffer.IsEmpty)
                {
                    metadataBuffer = new(new byte[LogEntryMetadata.Size]);
                }

                await reader.ReadBlockAsync(metadataBuffer).ConfigureAwait(false);

                metadata = new(metadataBuffer);
                consumed = false;
            }
예제 #3
0
            ValueTask IDataTransferObject.WriteToAsync <TWriter>(TWriter writer, CancellationToken token)
            {
                ValueTask result;

                if (consumed)
                {
                    result = new ValueTask(Task.FromException(new InvalidOperationException(ExceptionMessages.ReadLogEntryTwice)));
                }
                else
                {
                    consumed = true;
                    result   = reader.ReadBlockAsync(length, writer, token);
                }

                return(result);
            }