This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TestApp | |
{ | |
class Program | |
{ | |
private static ConnectionDetails _connectionDetails; | |
static async Task Main(string[] args) | |
{ | |
_connectionDetails = new ConnectionDetails() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async ValueTask<SearchResultValue> BinarySearchBlocks(ReadOnlyMemory<byte> key) | |
{ | |
var min = 0; | |
var max = _metaData.BlockCount - 1; | |
while (min <= max) | |
{ | |
var mid = (min + max) / 2; | |
using var block = await GetKVBlock(mid); | |
var result = block.TryFindKey(key.Span); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var remainder = outputSpan.Length; | |
ref var pointer = ref MemoryMarshal.GetReference(span); | |
var currentCrc = (uint)0; | |
while(remainder >= 4) | |
{ | |
var uintValue = Unsafe.As<byte, uint>(ref pointer); | |
currentCrc = System.Runtime.Intrinsics.X86.Sse42.Crc32(currentCrc, uintValue); | |
pointer = Unsafe.Add(ref pointer, 4); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Channels; | |
using System.Threading.Tasks; | |
using System.Threading.Tasks.Sources; | |
namespace RockR.Storage | |
{ | |
public class WriteAheadLog | |
{ | |
private Channel<QueueItem> _workQueue = Channel.CreateUnbounded<QueueItem>(new System.Threading.Channels.UnboundedChannelOptions() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static ReadOnlySpan<byte> NewLine => new byte[] { (byte)'\r', (byte)'\n' }; | |
static void Test() | |
{ | |
//const ReadOnlySpan<byte> eol = new byte[] { 13, 10 }; | |
var data = new byte[]{72,84,84,80,47,49,46,49,32,50, 48, 48, 32, 79, 75, 13, 10 | |
, 67, 111, 110, 116, 101, 110, 116, 45, 84, 121, 112, 101, 58, 32, 116, 101, 120, 116 | |
, 47, 112, 108, 97, 105, 110, 59, 32, 99, 104, 97, 114, 115, 101, 116, 61, 117, 116, 102 | |
, 45, 56, 13 }; | |
var ros = new ReadOnlySequence<byte>(data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static async Task RunLoopClient(int loopCount) | |
{ | |
var sw = System.Diagnostics.Stopwatch.StartNew(); | |
var sc = new ServiceCollection(); | |
var sp = sc.BuildServiceProvider(); | |
var client = new ClientBuilder(sp).UseSockets().Build(); | |
await using var connection = await client.ConnectAsync(new IPEndPoint(IPAddress.Loopback, 7777)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Bedrock.Framework; | |
using Bedrock.Framework.Protocols; | |
using Bedrock.Framework.Transports; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Logging; | |
using System; | |
using System.Net; | |
using System.Net.Http; | |
using System.Threading.Tasks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var host = new WebHostBuilder() | |
.UseKestrel(options => | |
{ | |
options.Listen(new IPEndPoint(IPAddress.Loopback, 5001), | |
lo => lo.UseTls()); | |
}) | |
.UseLibuv() | |
.UseContentRoot(Directory.GetCurrentDirectory()) | |
.UseStartup<Startup>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configuration> | |
<packageSources> | |
<add key="dotnet-corefxlab" value="https://dotnet.myget.org/F/dotnet-corefxlab/api/v3/index.json" /> | |
<add key="dotnet-corefx" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" /> | |
<add key="NuGet" value="https://api.nuget.org/v3/index.json" /> | |
<add key="aspnet" value="https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json" /> | |
</packageSources> | |
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static unsafe ushort ReadUShort(ref this ByteBufferReader reader) | |
{ | |
var firstSpan = reader.UnreadSegment; | |
ushort returnValue; | |
if (firstSpan.Length >= 2) | |
{ | |
returnValue = BinaryPrimitives.ReadUInt16BigEndian(firstSpan); | |
} | |
else | |
{ |
NewerOlder