Merge branch 'upstream'
Former-commit-id: efee1be6be6bea9f15017166f1bc7ae64fc37a1b
This commit is contained in:
commit
2b6c907a57
@ -1 +1 @@
|
||||
4f949ee4d3493ae84799bc004909d8c02cd95387
|
||||
4f583806bb8c4568601605309293ef257e338bf6
|
@ -1 +1 @@
|
||||
5bc587207ca36625c9e0ef11bedf144610db22df
|
||||
7f5772066f164630cebec71d176804ed59bd8c71
|
@ -1 +1 @@
|
||||
6ee3ca8968f7c2c5a13fde0d89329b4efbbd7f4f
|
||||
b7c15b7b9fa8148f527c4a789c88891b3083d91e
|
@ -1 +1 @@
|
||||
e2fe033997a386b136170ffee03d043df47c88df
|
||||
0b5f3952cc382be37d272154abe74be5a66a17ec
|
@ -1 +1 @@
|
||||
0aabd5e9b1f4b5f354b3f274cad6983bfa8434e8
|
||||
e666675a5e7c7a12e9a991ff5c40ea2427b626d2
|
@ -1 +1 @@
|
||||
caea80eb9a8aeae8d816300ba49e3e58a189a287
|
||||
1f3ffce45e728f3afdbcc4f62441ec66b01d28b9
|
@ -1 +1 @@
|
||||
f41727750b395e4019243785bcefced55377f2f3
|
||||
7f3bafeaee74306109dc28c841c32bf76b62e0a2
|
@ -1 +1 @@
|
||||
9a68bbd21ee9196ff71f50bc108c1324eae4f4f9
|
||||
4aceab7b6bffa92aab373aabde9c34d48d497e91
|
@ -10,7 +10,7 @@ namespace System.Buffers
|
||||
/// <summary>
|
||||
/// Provides a mechanism for manual lifetime management.
|
||||
/// </summary>
|
||||
public interface IRetainable
|
||||
interface IRetainable
|
||||
{
|
||||
/// <summary>
|
||||
/// Call this method to indicate that the IRetainable object is in use.
|
||||
|
@ -10,7 +10,7 @@ namespace System.Buffers
|
||||
/// <summary>
|
||||
/// A handle for the memory.
|
||||
/// </summary>
|
||||
public unsafe struct MemoryHandle : IDisposable
|
||||
unsafe struct MemoryHandle : IDisposable
|
||||
{
|
||||
private IRetainable _retainable;
|
||||
private void* _pointer;
|
||||
|
@ -10,7 +10,7 @@ namespace System.Buffers
|
||||
/// <summary>
|
||||
/// Owner of Memory<typeparamref name="T"/> that provides appropriate lifetime management mechanisms for it.
|
||||
/// </summary>
|
||||
public abstract class OwnedMemory<T> : IDisposable, IRetainable
|
||||
abstract class OwnedMemory<T> : IDisposable, IRetainable
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of items in the Memory<typeparamref name="T"/>.
|
||||
|
@ -239,7 +239,7 @@ namespace System
|
||||
/// Returns a handle for the array.
|
||||
/// <param name="pin">If pin is true, the GC will not move the array and hence its address can be taken</param>
|
||||
/// </summary>
|
||||
public unsafe MemoryHandle Retain(bool pin = false)
|
||||
unsafe MemoryHandle Retain(bool pin = false)
|
||||
{
|
||||
MemoryHandle memoryHandle = default;
|
||||
if (pin)
|
||||
|
@ -217,7 +217,7 @@ namespace System
|
||||
/// If pin is true, the GC will not move the array until the returned <see cref="MemoryHandle"/>
|
||||
/// is disposed, enabling the memory's address can be taken and used.
|
||||
/// </param>
|
||||
public unsafe MemoryHandle Retain(bool pin = false)
|
||||
unsafe MemoryHandle Retain(bool pin = false)
|
||||
{
|
||||
MemoryHandle memoryHandle = default;
|
||||
if (pin)
|
||||
|
@ -14,7 +14,7 @@ namespace System.Runtime.InteropServices
|
||||
/// Provides a collection of methods for interoperating with <see cref="Memory{T}"/>, <see cref="ReadOnlyMemory{T}"/>,
|
||||
/// <see cref="Span{T}"/>, and <see cref="ReadOnlySpan{T}"/>.
|
||||
/// </summary>
|
||||
public static class MemoryMarshal
|
||||
static class MemoryMarshal
|
||||
{
|
||||
/// <summary>Creates a <see cref="Memory{T}"/> from a <see cref="ReadOnlyMemory{T}"/>.</summary>
|
||||
/// <param name="readOnlyMemory">The <see cref="ReadOnlyMemory{T}"/>.</param>
|
||||
|
@ -19,6 +19,9 @@ using System.Diagnostics.Private;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
#if MONO
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace System.Collections.Concurrent
|
||||
{
|
||||
@ -56,11 +59,20 @@ namespace System.Collections.Concurrent
|
||||
}
|
||||
}
|
||||
|
||||
[NonSerialized]
|
||||
private volatile Tables _tables; // Internal tables of the dictionary
|
||||
private IEqualityComparer<TKey> _comparer; // Key equality comparer
|
||||
[NonSerialized]
|
||||
private readonly bool _growLockArray; // Whether to dynamically increase the size of the striped lock
|
||||
[NonSerialized]
|
||||
private int _budget; // The maximum number of elements per lock before a resize operation is triggered
|
||||
|
||||
#if MONO
|
||||
private KeyValuePair<TKey, TValue>[] _serializationArray; // Used for custom serialization
|
||||
private int _serializationConcurrencyLevel; // used to save the concurrency level in serialization
|
||||
private int _serializationCapacity; // used to save the capacity in serialization
|
||||
#endif
|
||||
|
||||
// The default capacity, i.e. the initial # of buckets. When choosing this value, we are making
|
||||
// a trade-off between the size of a very small dictionary, and the number of resizes when
|
||||
// constructing a large dictionary. Also, the capacity should not be divisible by a small prime.
|
||||
@ -2053,6 +2065,46 @@ namespace System.Collections.Concurrent
|
||||
_enumerator.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
#if MONO
|
||||
/// <summary>Get the data array to be serialized.</summary>
|
||||
[OnSerializing]
|
||||
private void OnSerializing(StreamingContext context)
|
||||
{
|
||||
Tables tables = _tables;
|
||||
|
||||
// save the data into the serialization array to be saved
|
||||
_serializationArray = ToArray();
|
||||
_serializationConcurrencyLevel = tables._locks.Length;
|
||||
_serializationCapacity = tables._buckets.Length;
|
||||
}
|
||||
|
||||
/// <summary>Clear the serialized state.</summary>
|
||||
[OnSerialized]
|
||||
private void OnSerialized(StreamingContext context)
|
||||
{
|
||||
_serializationArray = null;
|
||||
}
|
||||
|
||||
/// <summary>Construct the dictionary from a previously serialized one</summary>
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
KeyValuePair<TKey, TValue>[] array = _serializationArray;
|
||||
|
||||
var buckets = new Node[_serializationCapacity];
|
||||
var countPerLock = new int[_serializationConcurrencyLevel];
|
||||
var locks = new object[_serializationConcurrencyLevel];
|
||||
for (int i = 0; i < locks.Length; i++)
|
||||
{
|
||||
locks[i] = new object();
|
||||
}
|
||||
_tables = new Tables(buckets, locks, countPerLock);
|
||||
|
||||
InitializeFromCollection(array);
|
||||
_serializationArray = null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
internal sealed class IDictionaryDebugView<K, V>
|
||||
|
@ -180,7 +180,7 @@ namespace System.IO.Compression
|
||||
return _deflateStream.WriteAsync(array, offset, count, cancellationToken);
|
||||
}
|
||||
|
||||
public override Task WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
|
||||
internal override Task WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
if (GetType() != typeof(GZipStream))
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ namespace System.Buffers.Binary
|
||||
/// For native formats, MemoryExtensions.Read{T}; should be used.
|
||||
/// Use these helpers when you need to read specific endinanness.
|
||||
/// </remarks>
|
||||
public static partial class BinaryPrimitives
|
||||
static partial class BinaryPrimitives
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a no-op and added only for consistency.
|
||||
|
@ -6,7 +6,7 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System.Buffers.Binary
|
||||
{
|
||||
public static partial class BinaryPrimitives
|
||||
static partial class BinaryPrimitives
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads an Int16 out of a read-only span of bytes as big endian.
|
||||
|
@ -6,7 +6,7 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System.Buffers.Binary
|
||||
{
|
||||
public static partial class BinaryPrimitives
|
||||
static partial class BinaryPrimitives
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads an Int16 out of a read-only span of bytes as little endian.
|
||||
|
@ -11,7 +11,7 @@ using Internal.Runtime.CompilerServices;
|
||||
|
||||
namespace System.Buffers.Binary
|
||||
{
|
||||
public static partial class BinaryPrimitives
|
||||
static partial class BinaryPrimitives
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes a structure of type T into a span of bytes.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user