Skip to content

Instantly share code, notes, and snippets.

@zivillian
zivillian / AlignedSizedMemoryPool.cs
Last active May 3, 2020 18:29
32 byte aligned and pinned MemoryPool<T> without unsafe or fixed context for usage with Vector<T> and AVX
public static class AlignedSizedMemoryPool<T> where T:unmanaged
{
private const int ByteAlignment = 32;
private static readonly int SizeOf = StructSize.GetSize<T>(default);
private static readonly int Alignment = ByteAlignment / SizeOf;
public static IMemoryOwner<T> Rent(int bufferSize)
{
if (SizeOf == -1) throw new InvalidOperationException(String.Format("Type {0} cannot be aligned", typeof(T)));
return new SizedMemoryOwner(ArrayPool<T>.Shared.Rent(bufferSize + Alignment), bufferSize);
using System;
using System.Collections.Generic;
using System.Linq;
using Simple.OData.Client;
public class ODataDerivedTypeCustomConverter
{
private static readonly string AnnotationKey = "__annotations";
private readonly Type _baseType;
Simple.OData.Client.Core/ODataClient.Internals.cs | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/Simple.OData.Client.Core/ODataClient.Internals.cs b/Simple.OData.Client.Core/ODataClient.Internals.cs
index c79e0ac..53431d4 100644
--- a/Simple.OData.Client.Core/ODataClient.Internals.cs
+++ b/Simple.OData.Client.Core/ODataClient.Internals.cs
@@ -23,13 +23,16 @@ namespace Simple.OData.Client
var result = await ExecuteRequestWithResultAsync(request, cancellationToken,