Clone serialization toolkit for each user
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System.Formats.Cbor;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using mROA.Implementation;
|
||||
|
||||
public static class CborExtensions
|
||||
{
|
||||
public static unsafe void WriteToCbor(this RequestId id, CborWriter writer)
|
||||
{
|
||||
Span<byte> span = stackalloc byte[16];
|
||||
MemoryMarshal.Write(span, ref id);
|
||||
writer.WriteByteString(span);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe void WriteToCborInline(this RequestId id, CborWriter writer)
|
||||
{
|
||||
Span<byte> span = stackalloc byte[16];
|
||||
MemoryMarshal.Write(span, ref id);
|
||||
writer.WriteByteString(span);
|
||||
}
|
||||
|
||||
public static void WriteToDest(this RequestId id, Span<byte> destination)
|
||||
{
|
||||
MemoryMarshal.Write(destination, ref id);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||
public static unsafe void WriteToCborOpt(this RequestId id, CborWriter writer)
|
||||
{
|
||||
Span<byte> span = stackalloc byte[16];
|
||||
MemoryMarshal.Write(span, ref id);
|
||||
writer.WriteByteString(span);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,8 @@
|
||||
// See https://aka.ms/new-console-template for more information
|
||||
|
||||
using System.Formats.Cbor;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using BenchmarkDotNet.Running;
|
||||
using mROA.Benchmark;
|
||||
using mROA.Implementation;
|
||||
|
||||
Console.WriteLine("Hello, World!");
|
||||
var test = new CborTest();
|
||||
test.ArrayWrite();
|
||||
|
||||
BenchmarkRunner.Run<IdGeneration>();
|
||||
|
||||
public static class CborExtensions
|
||||
{
|
||||
public static unsafe void WriteToCbor(this RequestId id, CborWriter writer)
|
||||
{
|
||||
Span<byte> span = stackalloc byte[16];
|
||||
MemoryMarshal.Write(span, ref id);
|
||||
writer.WriteByteString(span);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe void WriteToCborInline(this RequestId id, CborWriter writer)
|
||||
{
|
||||
Span<byte> span = stackalloc byte[16];
|
||||
MemoryMarshal.Write(span, ref id);
|
||||
writer.WriteByteString(span);
|
||||
}
|
||||
|
||||
public static void WriteToDest(this RequestId id, Span<byte> destination)
|
||||
{
|
||||
MemoryMarshal.Write(destination, ref id);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||
public static unsafe void WriteToCborOpt(this RequestId id, CborWriter writer)
|
||||
{
|
||||
Span<byte> span = stackalloc byte[16];
|
||||
MemoryMarshal.Write(span, ref id);
|
||||
writer.WriteByteString(span);
|
||||
}
|
||||
}
|
||||
@@ -25,15 +25,15 @@ namespace mROA.Implementation.Backend
|
||||
|
||||
public IRequestExtractor this[int id] => _producedExtractors[id];
|
||||
|
||||
public IRequestExtractor HubOnOnConnected(IRepresentationModule interaction)
|
||||
public IRequestExtractor HubOnOnConnected(IRepresentationModule representationModule)
|
||||
{
|
||||
var extractor = CreateExtractor(interaction);
|
||||
var extractor = CreateExtractor(representationModule);
|
||||
if (_mode.DistributionType == EDistributionType.Channeled)
|
||||
{
|
||||
extractor.StartExtraction().ContinueWith(_ => OnDisconnected(interaction));
|
||||
extractor.StartExtraction().ContinueWith(_ => OnDisconnected(representationModule));
|
||||
}
|
||||
|
||||
_producedExtractors[interaction.Id] = extractor;
|
||||
_producedExtractors[representationModule.Id] = extractor;
|
||||
return extractor;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace mROA.Implementation.Backend
|
||||
_extractorsTokenSources[interaction.ConnectionId] = cts;
|
||||
|
||||
_hub.RegisterInteraction(interaction);
|
||||
var requestExtractor = _hre.HubOnOnConnected(new RepresentationModule(interaction, _serialization));
|
||||
var requestExtractor = _hre.HubOnOnConnected(new RepresentationModule(interaction, _serialization.Clone()));
|
||||
|
||||
if (_distribution.DistributionType != EDistributionType.Channeled)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace mROA.Implementation
|
||||
{
|
||||
var interaction = _hub.GetInteraction(id);
|
||||
|
||||
var produced = new RepresentationModule(interaction, _serialization);
|
||||
var produced = new RepresentationModule(interaction, _serialization.Clone());
|
||||
|
||||
return produced;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user