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 class BigEndianReaders | |
{ | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static ushort ReadUInt16(ref ReadableBuffer buffer) | |
{ | |
var returnValue = PeekUInt16(buffer); | |
buffer = buffer.Slice(2); | |
return returnValue; | |
} |
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
ReadableBuffer currentPayload; | |
int expectedPayloadSize = 0; | |
while (true) | |
{ | |
var result = await _lowerConnection.Input.ReadAsync(); | |
var buffer = result.Buffer; | |
try | |
{ | |
if (buffer.IsEmpty && result.IsCompleted) | |
{ |
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 void Main(string[] args) | |
{ | |
var x = Flip(10000); | |
var y = FlipNew(10000); | |
////var bench = new ReverseBench(); | |
////bench.FlipInSets64Bit(); | |
//BenchmarkRunner.Run<ReverseBench>(); | |
} | |
public unsafe static ulong Flip(ulong val) |
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
class Program | |
{ | |
private static readonly TestStruct _Account = new TestStruct(); | |
static void Main(string[] args) | |
{ | |
Console.WriteLine(_Account.MyMoney); | |
_Account.UpdateValue(100); | |
Console.WriteLine(_Account.MyMoney); |
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.Buffers; | |
using System.Buffers.Pools; | |
using System.IO.Pipelines; | |
using System.Runtime.InteropServices; | |
namespace Leto.BulkCipher | |
{ | |
public sealed class AeadBulkCipher : IDisposable | |
{ |
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 Leto.Hash; | |
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
namespace Leto.Hash | |
{ | |
public static class PsuedoRandomExtensions | |
{ | |
//https://tools.ietf.org/html/rfc5246#section-4.7 |
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 struct BigEndianSpanReader | |
{ | |
private Span<byte> _span; | |
public BigEndianSpanReader(Span<byte> span) | |
{ | |
_span = span; | |
} | |
public int Length => _span.Length; |
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 Task WritingLoop() | |
{ | |
while(true) | |
{ | |
var reader = Task.WhenAny(_handshakePipe.Reader.ReadAsync(), _inputPipe.Reader.ReadAsync()); | |
RecordType recordType; | |
if (reader == handshakeReader) | |
{ | |
recordType = RecordType.Handshake; | |
} |
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
[Fact] | |
public void TestSyncBuffer() | |
{ | |
var bytes = Encoding.UTF8.GetBytes("Hello there"); | |
using (var factory = new PipeFactory()) | |
{ | |
var pipe = factory.Create(); | |
var test = pipe.Writer.Alloc(); | |
test.Write(bytes); | |
test.Commit(); |
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.Collections.Generic; | |
public class ReloadingCache | |
{ | |
private List<string> _cachedItems; | |
private System.Threading.Timer _timer; | |
public ReloadingCache() | |
{ | |
//Load the first lot of data to stop consumers getting null |
OlderNewer