add a scanner, but this seems to be a wrong solution. Change open-source head
This commit is contained in:
@@ -8,33 +8,12 @@
|
|||||||
<Item Id="{2b7014a2-6093-4095-ad6d-799b52ef74e0}">
|
<Item Id="{2b7014a2-6093-4095-ad6d-799b52ef74e0}">
|
||||||
<Items>
|
<Items>
|
||||||
<Item Id="{b3ec38a7-ed71-4ab9-9a43-1623fc3d4c30}">
|
<Item Id="{b3ec38a7-ed71-4ab9-9a43-1623fc3d4c30}">
|
||||||
<Expansion>//-----------------------------------------------------------------------
|
<Expansion>// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="«?FileBase»"
|
// file="«?FileBase»"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: «?GetUserInfo(Company)»
|
// Copyright (c) «?GetUserInfo(Company)».
|
||||||
// Copyright (c) «?GetUserInfo(Company)». All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------</Expansion>
|
||||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
//of this software and associated documentation files (the "Software"), to deal
|
|
||||||
//in the Software without restriction, including without limitation the rights
|
|
||||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
//copies of the Software, and to permit persons to whom the Software is
|
|
||||||
//furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
//The above copyright notice and this permission notice shall be included in all
|
|
||||||
//copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
//SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------</Expansion>
|
|
||||||
</Item>
|
</Item>
|
||||||
</Items>
|
</Items>
|
||||||
</Item>
|
</Item>
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
// file="HlsfAllocatorBench"
|
||||||
// file="TlsfAllocatorBench"
|
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
using StgSharp.HighPerformance.Memory;
|
using StgSharp.HighPerformance.Memory;
|
||||||
using System;
|
using System;
|
||||||
@@ -72,14 +52,6 @@ namespace StgSharp.Benchmark
|
|||||||
_libcLocalList.TrimExcess();
|
_libcLocalList.TrimExcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Benchmark(OperationsPerInvoke = TotalOperationsPerInvoke)]
|
|
||||||
public void Tlsf()
|
|
||||||
{
|
|
||||||
for (int batch = 0; batch < BatchCount; batch++) {
|
|
||||||
RunTlsf(batch, _tlsfAllocator, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[IterationCleanup]
|
[IterationCleanup]
|
||||||
public void IterationCleanup()
|
public void IterationCleanup()
|
||||||
{
|
{
|
||||||
@@ -108,6 +80,14 @@ namespace StgSharp.Benchmark
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Benchmark(OperationsPerInvoke = TotalOperationsPerInvoke)]
|
||||||
|
public void Tlsf()
|
||||||
|
{
|
||||||
|
for (int batch = 0; batch < BatchCount; batch++) {
|
||||||
|
RunTlsf(batch, _tlsfAllocator, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static uint AlignSize(
|
private static uint AlignSize(
|
||||||
uint size
|
uint size
|
||||||
)
|
)
|
||||||
@@ -150,27 +130,6 @@ namespace StgSharp.Benchmark
|
|||||||
return (nuint)mb * 1024u * 1024u;
|
return (nuint)mb * 1024u * 1024u;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunTlsf(
|
|
||||||
int batch,
|
|
||||||
TwoLayerSegregatedFitAllocator allocator,
|
|
||||||
int scanWindow = 4
|
|
||||||
)
|
|
||||||
{
|
|
||||||
int batchOffset = batch * AllocationCount;
|
|
||||||
_tlsfLocalList.Clear();
|
|
||||||
|
|
||||||
for (int i = 0; i < AllocationCount; i++)
|
|
||||||
{
|
|
||||||
uint size = _requestSizesByBatch[batchOffset + i];
|
|
||||||
Tlsf.Handle allocate = allocator.Alloc(size);
|
|
||||||
_tlsfLocalList.Add(allocate);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < _tlsfLocalList.Count; i++) {
|
|
||||||
allocator.Free(_tlsfLocalList[_freeOrderByBatch[batchOffset + i]], scanWindow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private unsafe void RunLibc(
|
private unsafe void RunLibc(
|
||||||
int batch
|
int batch
|
||||||
)
|
)
|
||||||
@@ -193,6 +152,27 @@ namespace StgSharp.Benchmark
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RunTlsf(
|
||||||
|
int batch,
|
||||||
|
TwoLayerSegregatedFitAllocator allocator,
|
||||||
|
int scanWindow = 4
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int batchOffset = batch * AllocationCount;
|
||||||
|
_tlsfLocalList.Clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < AllocationCount; i++)
|
||||||
|
{
|
||||||
|
uint size = _requestSizesByBatch[batchOffset + i];
|
||||||
|
Tlsf.Handle allocate = allocator.Alloc(size);
|
||||||
|
_tlsfLocalList.Add(allocate);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _tlsfLocalList.Count; i++) {
|
||||||
|
allocator.Free(_tlsfLocalList[_freeOrderByBatch[batchOffset + i]], scanWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ShuffleFreeOrder(
|
private void ShuffleFreeOrder(
|
||||||
int offset,
|
int offset,
|
||||||
int count
|
int count
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="Program"
|
// file="Program"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using BenchmarkDotNet.Configs;
|
using BenchmarkDotNet.Configs;
|
||||||
using BenchmarkDotNet.Jobs;
|
using BenchmarkDotNet.Jobs;
|
||||||
using BenchmarkDotNet.Loggers;
|
using BenchmarkDotNet.Loggers;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="SwissBenchmark"
|
// file="SwissBenchmark"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
using StgSharp.Collections;
|
using StgSharp.Collections;
|
||||||
using System;
|
using System;
|
||||||
@@ -35,11 +15,11 @@ namespace StgSharp.Benchmark
|
|||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Benchmark comparing SwissTable against <see cref="Dictionary{TKey, TValue}" /> under
|
/// Benchmark comparing SwissTable against <see cref="Dictionary{TKey, TValue}" /> under
|
||||||
/// realistic L4 software cache address-mapping workloads. <para> /// L4 scenario
|
/// realistic L4 software cache address-mapping workloads. <para>/// L4 scenario
|
||||||
/// characteristics: /// - Keys are HLSF/malloc pointer addresses (large, 1024-byte aligned)
|
/// characteristics: /// - Keys are HLSF/malloc pointer addresses (large, 1024-byte aligned)
|
||||||
/// /// - Access pattern is Zipfian-skewed (20% hot cache lines receive 80% of lookups) ///
|
/// /// - Access pattern is Zipfian-skewed (20% hot cache lines receive 80% of lookups) ///
|
||||||
/// - Steady state: high hit-rate lookups dominate, with rare evict+refill on miss /// -
|
/// - Steady state: high hit-rate lookups dominate, with rare evict+refill on miss /// -
|
||||||
/// Working set: 512–4096 active cache line mappings ///</para>
|
/// Working set: 512–4096 active cache line mappings /// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MemoryDiagnoser]
|
[MemoryDiagnoser]
|
||||||
public class SwissTableBench
|
public class SwissTableBench
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="BidirectionalDictionary"
|
// file="BidirectionalDictionary"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -34,8 +14,8 @@ using System.Linq;
|
|||||||
namespace StgSharp.Collections
|
namespace StgSharp.Collections
|
||||||
{
|
{
|
||||||
public sealed class BidirectionalDictionary<TFirst, TSecond> : IBidirectionalDictionary<TFirst, TSecond>
|
public sealed class BidirectionalDictionary<TFirst, TSecond> : IBidirectionalDictionary<TFirst, TSecond>
|
||||||
where TFirst: notnull
|
where TFirst : notnull
|
||||||
where TSecond: notnull
|
where TSecond : notnull
|
||||||
{
|
{
|
||||||
|
|
||||||
private readonly Dictionary<TFirst, TSecond> _forward;
|
private readonly Dictionary<TFirst, TSecond> _forward;
|
||||||
@@ -47,7 +27,9 @@ namespace StgSharp.Collections
|
|||||||
_reverse = [];
|
_reverse = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public TFirst this[TSecond key]
|
public TFirst this[
|
||||||
|
TSecond key
|
||||||
|
]
|
||||||
{
|
{
|
||||||
get => _reverse.TryGetValue(key, out TFirst value) ?
|
get => _reverse.TryGetValue(key, out TFirst value) ?
|
||||||
value :
|
value :
|
||||||
@@ -66,7 +48,9 @@ namespace StgSharp.Collections
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TSecond this[TFirst key]
|
public TSecond this[
|
||||||
|
TFirst key
|
||||||
|
]
|
||||||
{
|
{
|
||||||
get => _forward.TryGetValue(key, out TSecond value) ?
|
get => _forward.TryGetValue(key, out TSecond value) ?
|
||||||
value :
|
value :
|
||||||
@@ -99,7 +83,9 @@ namespace StgSharp.Collections
|
|||||||
public IReadOnlyDictionary<TSecond, TFirst> Reverse => new ReadOnlyDictionary<TSecond, TFirst>(
|
public IReadOnlyDictionary<TSecond, TFirst> Reverse => new ReadOnlyDictionary<TSecond, TFirst>(
|
||||||
_reverse);
|
_reverse);
|
||||||
|
|
||||||
public void Add(KeyValuePair<TFirst, TSecond> item)
|
public void Add(
|
||||||
|
KeyValuePair<TFirst, TSecond> item
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (_forward.ContainsKey(item.Key) || _reverse.ContainsKey(item.Value)) {
|
if (_forward.ContainsKey(item.Key) || _reverse.ContainsKey(item.Value)) {
|
||||||
throw new ArgumentException("Duplicate key or value.");
|
throw new ArgumentException("Duplicate key or value.");
|
||||||
@@ -108,7 +94,10 @@ namespace StgSharp.Collections
|
|||||||
_reverse.Add(item.Value, item.Key);
|
_reverse.Add(item.Value, item.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(TFirst key, TSecond value)
|
public void Add(
|
||||||
|
TFirst key,
|
||||||
|
TSecond value
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (_forward.ContainsKey(key) || _reverse.ContainsKey(value)) {
|
if (_forward.ContainsKey(key) || _reverse.ContainsKey(value)) {
|
||||||
throw new ArgumentException("Duplicate key or value.");
|
throw new ArgumentException("Duplicate key or value.");
|
||||||
@@ -123,22 +112,33 @@ namespace StgSharp.Collections
|
|||||||
_reverse.Clear();
|
_reverse.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Contains(KeyValuePair<TFirst, TSecond> item)
|
public bool Contains(
|
||||||
|
KeyValuePair<TFirst, TSecond> item
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return _forward.Contains(item) && _reverse.TryGetValue(item.Value, out TFirst var) && var!.Equals(item.Key);
|
return _forward.Contains(item) &&
|
||||||
|
_reverse.TryGetValue(item.Value, out TFirst var) &&
|
||||||
|
var!.Equals(item.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Contains(TSecond key)
|
public bool Contains(
|
||||||
|
TSecond key
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return _reverse.ContainsKey(key);
|
return _reverse.ContainsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Contains(TFirst key)
|
public bool Contains(
|
||||||
|
TFirst key
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return _forward.ContainsKey(key);
|
return _forward.ContainsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CopyTo(KeyValuePair<TFirst, TSecond>[] array, int arrayIndex)
|
public void CopyTo(
|
||||||
|
KeyValuePair<TFirst, TSecond>[] array,
|
||||||
|
int arrayIndex
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
throw new ArgumentNullException(nameof(array));
|
throw new ArgumentNullException(nameof(array));
|
||||||
@@ -162,12 +162,16 @@ namespace StgSharp.Collections
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(TFirst key)
|
public bool Remove(
|
||||||
|
TFirst key
|
||||||
|
)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(KeyValuePair<TFirst, TSecond> item)
|
public bool Remove(
|
||||||
|
KeyValuePair<TFirst, TSecond> item
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (_forward.Remove(item.Key)) {
|
if (_forward.Remove(item.Key)) {
|
||||||
return _reverse.Remove(item.Value);
|
return _reverse.Remove(item.Value);
|
||||||
@@ -175,12 +179,18 @@ namespace StgSharp.Collections
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetValue(TFirst key, out TSecond value)
|
public bool TryGetValue(
|
||||||
|
TFirst key,
|
||||||
|
out TSecond value
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return _forward.TryGetValue(key, out value);
|
return _forward.TryGetValue(key, out value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetValue(TSecond key, out TFirst value)
|
public bool TryGetValue(
|
||||||
|
TSecond key,
|
||||||
|
out TFirst value
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return _reverse.TryGetValue(key, out value);
|
return _reverse.TryGetValue(key, out value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="CapacityFixedBag"
|
// file="CapacityFixedBag"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -37,7 +17,9 @@ namespace StgSharp.Collections
|
|||||||
|
|
||||||
private readonly T[] _buffer;
|
private readonly T[] _buffer;
|
||||||
|
|
||||||
public CapacityFixedBag(int capacity)
|
public CapacityFixedBag(
|
||||||
|
int capacity
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_buffer = new T[capacity];
|
_buffer = new T[capacity];
|
||||||
}
|
}
|
||||||
@@ -46,7 +28,9 @@ namespace StgSharp.Collections
|
|||||||
|
|
||||||
public int Capacity => _buffer.Length;
|
public int Capacity => _buffer.Length;
|
||||||
|
|
||||||
public void Add(T item)
|
public void Add(
|
||||||
|
T item
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (Count >= _buffer.Length) {
|
if (Count >= _buffer.Length) {
|
||||||
throw new InvalidOperationException("Bag capacity exceeded.");
|
throw new InvalidOperationException("Bag capacity exceeded.");
|
||||||
@@ -62,7 +46,9 @@ namespace StgSharp.Collections
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Remove(T item)
|
public void Remove(
|
||||||
|
T item
|
||||||
|
)
|
||||||
{
|
{
|
||||||
int index = Array.IndexOf(_buffer, item, 0, Count);
|
int index = Array.IndexOf(_buffer, item, 0, Count);
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
@@ -73,7 +59,9 @@ namespace StgSharp.Collections
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveAt(int index)
|
public void RemoveAt(
|
||||||
|
int index
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="CapacityFixedList"
|
// file="CapacityFixedList"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="CapacityFixedStack"
|
// file="CapacityFixedStack"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -42,7 +22,9 @@ namespace StgSharp.Collections
|
|||||||
// _index points to the next free slot (top empty position). Therefore Count == _index.
|
// _index points to the next free slot (top empty position). Therefore Count == _index.
|
||||||
private int _index;
|
private int _index;
|
||||||
|
|
||||||
public CapacityFixedStack(int size)
|
public CapacityFixedStack(
|
||||||
|
int size
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ArgumentOutOfRangeException.ThrowIfNegative(size);
|
ArgumentOutOfRangeException.ThrowIfNegative(size);
|
||||||
_values = new T[size];
|
_values = new T[size];
|
||||||
@@ -99,7 +81,9 @@ namespace StgSharp.Collections
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public T[] PopRange(int count)
|
public T[] PopRange(
|
||||||
|
int count
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (count <= 0 || _index == 0) {
|
if (count <= 0 || _index == 0) {
|
||||||
return Array.Empty<T>();
|
return Array.Empty<T>();
|
||||||
@@ -113,7 +97,9 @@ namespace StgSharp.Collections
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Push(T item)
|
public void Push(
|
||||||
|
T item
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (_index >= _values.Length) {
|
if (_index >= _values.Length) {
|
||||||
throw new InvalidOperationException("Stack is full.");
|
throw new InvalidOperationException("Stack is full.");
|
||||||
@@ -122,7 +108,9 @@ namespace StgSharp.Collections
|
|||||||
_index++;
|
_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PushRange(ReadOnlySpan<T> span)
|
public void PushRange(
|
||||||
|
ReadOnlySpan<T> span
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (span.Length == 0) {
|
if (span.Length == 0) {
|
||||||
return;
|
return;
|
||||||
@@ -134,7 +122,9 @@ namespace StgSharp.Collections
|
|||||||
_index += span.Length;
|
_index += span.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryPop(out T value)
|
public bool TryPop(
|
||||||
|
out T value
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (_index == 0)
|
if (_index == 0)
|
||||||
{
|
{
|
||||||
@@ -163,7 +153,9 @@ namespace StgSharp.Collections
|
|||||||
public static class CapacityFixedStackBuilder
|
public static class CapacityFixedStackBuilder
|
||||||
{
|
{
|
||||||
|
|
||||||
public static CapacityFixedStack<T> Create<T>(ReadOnlySpan<T> values)
|
public static CapacityFixedStack<T> Create<T>(
|
||||||
|
ReadOnlySpan<T> values
|
||||||
|
)
|
||||||
{
|
{
|
||||||
CapacityFixedStack<T> stack = new(values.Length);
|
CapacityFixedStack<T> stack = new(values.Length);
|
||||||
stack.PushRange(values); // Push in order
|
stack.PushRange(values); // Push in order
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="ConcurrentCapacityFixedStack"
|
// file="ConcurrentCapacityFixedStack"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -51,7 +31,9 @@ namespace StgSharp.Collections
|
|||||||
// Next push position (0.._capacity). Only modified via CAS.
|
// Next push position (0.._capacity). Only modified via CAS.
|
||||||
private int _top;
|
private int _top;
|
||||||
|
|
||||||
public ConcurrentCapacityFixedStack(int capacity)
|
public ConcurrentCapacityFixedStack(
|
||||||
|
int capacity
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (capacity <= 0) {
|
if (capacity <= 0) {
|
||||||
throw new ArgumentOutOfRangeException(nameof(capacity));
|
throw new ArgumentOutOfRangeException(nameof(capacity));
|
||||||
@@ -102,7 +84,9 @@ namespace StgSharp.Collections
|
|||||||
throw new InvalidOperationException("Stack is empty.");
|
throw new InvalidOperationException("Stack is empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public T[] PopRange(int count)
|
public T[] PopRange(
|
||||||
|
int count
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
return [];
|
return [];
|
||||||
@@ -130,7 +114,9 @@ namespace StgSharp.Collections
|
|||||||
return trimmed;
|
return trimmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Push(T item)
|
public void Push(
|
||||||
|
T item
|
||||||
|
)
|
||||||
{
|
{
|
||||||
SpinWait sw = default;
|
SpinWait sw = default;
|
||||||
while (true)
|
while (true)
|
||||||
@@ -154,7 +140,9 @@ namespace StgSharp.Collections
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PushRange(ReadOnlySpan<T> span)
|
public void PushRange(
|
||||||
|
ReadOnlySpan<T> span
|
||||||
|
)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < span.Length; i++) {
|
for (int i = 0; i < span.Length; i++) {
|
||||||
Push(span[i]);
|
Push(span[i]);
|
||||||
@@ -192,7 +180,9 @@ namespace StgSharp.Collections
|
|||||||
return trimmed;
|
return trimmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryPeek(out T value)
|
public bool TryPeek(
|
||||||
|
out T value
|
||||||
|
)
|
||||||
{
|
{
|
||||||
value = default!;
|
value = default!;
|
||||||
SpinWait sw = default;
|
SpinWait sw = default;
|
||||||
@@ -227,7 +217,9 @@ namespace StgSharp.Collections
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryPop(out T value)
|
public bool TryPop(
|
||||||
|
out T value
|
||||||
|
)
|
||||||
{
|
{
|
||||||
value = default!;
|
value = default!;
|
||||||
SpinWait sw = default;
|
SpinWait sw = default;
|
||||||
@@ -264,7 +256,9 @@ namespace StgSharp.Collections
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int TryPopRange(Span<T> destination)
|
public int TryPopRange(
|
||||||
|
Span<T> destination
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (destination.IsEmpty) {
|
if (destination.IsEmpty) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -281,7 +275,10 @@ namespace StgSharp.Collections
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-26
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
// file="ConcurrentFlexibleArray"
|
||||||
// file="ConcurrentFlexibaleArray"
|
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="IBidirectionalDictionary"
|
// file="IBidirectionalDictionary"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace StgSharp.Collections
|
namespace StgSharp.Collections
|
||||||
@@ -32,7 +12,9 @@ namespace StgSharp.Collections
|
|||||||
public interface IBidirectionalDictionary<TFirst, TSecond> : IDictionary<TFirst, TSecond>
|
public interface IBidirectionalDictionary<TFirst, TSecond> : IDictionary<TFirst, TSecond>
|
||||||
{
|
{
|
||||||
|
|
||||||
TFirst this[TSecond key] { get; set; }
|
TFirst this[
|
||||||
|
TSecond key
|
||||||
|
] { get; set; }
|
||||||
|
|
||||||
ICollection<TFirst> FirstIndex { get; }
|
ICollection<TFirst> FirstIndex { get; }
|
||||||
|
|
||||||
@@ -53,7 +35,9 @@ namespace StgSharp.Collections
|
|||||||
/// true if the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains an element with
|
/// true if the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains an element with
|
||||||
/// the specified key; otherwise, false.
|
/// the specified key; otherwise, false.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
bool Contains(TSecond key);
|
bool Contains(
|
||||||
|
TSecond key
|
||||||
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines whether the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains the
|
/// Determines whether the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains the
|
||||||
@@ -66,16 +50,23 @@ namespace StgSharp.Collections
|
|||||||
/// true if the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains an element with
|
/// true if the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains an element with
|
||||||
/// the specified key; otherwise, false.
|
/// the specified key; otherwise, false.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
bool Contains(TFirst key);
|
bool Contains(
|
||||||
|
TFirst key
|
||||||
|
);
|
||||||
|
|
||||||
bool TryGetValue(TSecond key, out TFirst value);
|
bool TryGetValue(
|
||||||
|
TSecond key,
|
||||||
|
out TFirst value
|
||||||
|
);
|
||||||
|
|
||||||
#pragma warning disable CA1033
|
#pragma warning disable CA1033
|
||||||
ICollection<TFirst> IDictionary<TFirst, TSecond>.Keys => FirstIndex;
|
ICollection<TFirst> IDictionary<TFirst, TSecond>.Keys => FirstIndex;
|
||||||
|
|
||||||
ICollection<TSecond> IDictionary<TFirst, TSecond>.Values => SecondIndex;
|
ICollection<TSecond> IDictionary<TFirst, TSecond>.Values => SecondIndex;
|
||||||
|
|
||||||
bool IDictionary<TFirst, TSecond>.ContainsKey(TFirst key)
|
bool IDictionary<TFirst, TSecond>.ContainsKey(
|
||||||
|
TFirst key
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return Contains(key);
|
return Contains(key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="LinearBag"
|
// file="LinearBag"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="ListSegment"
|
// file="ListSegment"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="RandomAccessibleStack"
|
// file="RandomAccessibleStack"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -53,7 +33,9 @@ namespace StgSharp.Collections
|
|||||||
/// Initializes a new instance of the RandomAccessStack class that is empty and has the
|
/// Initializes a new instance of the RandomAccessStack class that is empty and has the
|
||||||
/// specified initial capacity.
|
/// specified initial capacity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RandomAccessibleStack(int capacity)
|
public RandomAccessibleStack(
|
||||||
|
int capacity
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (capacity < 0) {
|
if (capacity < 0) {
|
||||||
throw new ArgumentOutOfRangeException(
|
throw new ArgumentOutOfRangeException(
|
||||||
@@ -67,7 +49,9 @@ namespace StgSharp.Collections
|
|||||||
/// Gets or sets the element at the specified index in the stack (0 = bottom, Count-1 =
|
/// Gets or sets the element at the specified index in the stack (0 = bottom, Count-1 =
|
||||||
/// top).
|
/// top).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public T this[int index]
|
public T this[
|
||||||
|
int index
|
||||||
|
]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -152,7 +136,9 @@ namespace StgSharp.Collections
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds an item to the top of the stack.
|
/// Adds an item to the top of the stack.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Push(T item)
|
public void Push(
|
||||||
|
T item
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (_size == _array.Length) {
|
if (_size == _array.Length) {
|
||||||
EnsureCapacity(_size + 1);
|
EnsureCapacity(_size + 1);
|
||||||
@@ -162,7 +148,9 @@ namespace StgSharp.Collections
|
|||||||
_version++;
|
_version++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnsureCapacity(int min)
|
private void EnsureCapacity(
|
||||||
|
int min
|
||||||
|
)
|
||||||
{
|
{
|
||||||
int newCapacity = _array.Length == 0 ? DefaultCapacity : _array.Length * 2;
|
int newCapacity = _array.Length == 0 ? DefaultCapacity : _array.Length * 2;
|
||||||
if (newCapacity < min) {
|
if (newCapacity < min) {
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="SwissTable.X86"
|
// file="SwissTable.X86"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.Intrinsics;
|
using System.Runtime.Intrinsics;
|
||||||
|
|||||||
@@ -1,33 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
// file="SwissTable"
|
||||||
// file="SwissTable.cs"
|
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person
|
|
||||||
// obtaining a copy of this software and associated documentation
|
|
||||||
// files (the “Software”), to deal in the Software without restriction,
|
|
||||||
// including without limitation the rights to use, copy, modify, merge,
|
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
// and to permit persons to whom the Software is furnished to do so,
|
|
||||||
// subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and
|
|
||||||
// this permission notice shall be included in all copies
|
|
||||||
// or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
|
||||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
||||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
|
||||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
@@ -55,7 +32,10 @@ namespace StgSharp.Collections
|
|||||||
private readonly Action<nuint> _freeHandle;
|
private readonly Action<nuint> _freeHandle;
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
private SwissTable(Entry* buffer, Action<nuint> freeHandle)
|
private SwissTable(
|
||||||
|
Entry* buffer,
|
||||||
|
Action<nuint> freeHandle
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_entries = buffer;
|
_entries = buffer;
|
||||||
_freeHandle = freeHandle;
|
_freeHandle = freeHandle;
|
||||||
@@ -72,7 +52,10 @@ namespace StgSharp.Collections
|
|||||||
return new SwissTable(buffer, handle => NativeMemory.AlignedFree((void*)handle));
|
return new SwissTable(buffer, handle => NativeMemory.AlignedFree((void*)handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SwissTable Create(Func<nuint, nuint> allocator, Action<nuint> freeHandle)
|
public static SwissTable Create(
|
||||||
|
Func<nuint, nuint> allocator,
|
||||||
|
Action<nuint> freeHandle
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Entry* buffer = (Entry*)allocator(RequestedNativeMemorySize);
|
Entry* buffer = (Entry*)allocator(RequestedNativeMemorySize);
|
||||||
for (int i = 0; i < BucketCount; i++)
|
for (int i = 0; i < BucketCount; i++)
|
||||||
@@ -93,7 +76,11 @@ namespace StgSharp.Collections
|
|||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryAddOrSet(nuint key, nuint value, out bool isNewKey)
|
public bool TryAddOrSet(
|
||||||
|
nuint key,
|
||||||
|
nuint value,
|
||||||
|
out bool isNewKey
|
||||||
|
)
|
||||||
{
|
{
|
||||||
uint hash = BitOperations.Crc32C(CrcMagic, (ulong)key);
|
uint hash = BitOperations.Crc32C(CrcMagic, (ulong)key);
|
||||||
ushort entry = (ushort)(hash & (BucketCount - 1));
|
ushort entry = (ushort)(hash & (BucketCount - 1));
|
||||||
@@ -101,7 +88,10 @@ namespace StgSharp.Collections
|
|||||||
return IBucketScanner.Current.TrySet(key, hash, bucket, value, out isNewKey);
|
return IBucketScanner.Current.TrySet(key, hash, bucket, value, out isNewKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGet(nuint key, out nuint value)
|
public bool TryGet(
|
||||||
|
nuint key,
|
||||||
|
out nuint value
|
||||||
|
)
|
||||||
{
|
{
|
||||||
uint hash = BitOperations.Crc32C(CrcMagic, key);
|
uint hash = BitOperations.Crc32C(CrcMagic, key);
|
||||||
ushort entry = (ushort)(hash & (BucketCount - 1));
|
ushort entry = (ushort)(hash & (BucketCount - 1));
|
||||||
@@ -116,7 +106,10 @@ namespace StgSharp.Collections
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryRemove(nuint key, out nuint value)
|
public bool TryRemove(
|
||||||
|
nuint key,
|
||||||
|
out nuint value
|
||||||
|
)
|
||||||
{
|
{
|
||||||
uint hash = BitOperations.Crc32C(CrcMagic, key);
|
uint hash = BitOperations.Crc32C(CrcMagic, key);
|
||||||
ushort entry = (ushort)(hash & (BucketCount - 1));
|
ushort entry = (ushort)(hash & (BucketCount - 1));
|
||||||
@@ -124,7 +117,10 @@ namespace StgSharp.Collections
|
|||||||
return IBucketScanner.Current.TryRemove(key, hash, bucket, out value);
|
return IBucketScanner.Current.TryRemove(key, hash, bucket, out value);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static SwissTable Create(nuint bufferPtr, Action<nuint> FreeHandle)
|
internal static SwissTable Create(
|
||||||
|
nuint bufferPtr,
|
||||||
|
Action<nuint> FreeHandle
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Entry* buffer = (Entry*)bufferPtr;
|
Entry* buffer = (Entry*)bufferPtr;
|
||||||
for (int i = 0; i < BucketCount; i++)
|
for (int i = 0; i < BucketCount; i++)
|
||||||
@@ -162,11 +158,27 @@ namespace StgSharp.Collections
|
|||||||
|
|
||||||
static IBucketScanner Current { get; } = Create();
|
static IBucketScanner Current { get; } = Create();
|
||||||
|
|
||||||
bool TryFind(nuint key, uint Hash, Bucket* bucket, out nuint value);
|
bool TryFind(
|
||||||
|
nuint key,
|
||||||
|
uint Hash,
|
||||||
|
Bucket* bucket,
|
||||||
|
out nuint value
|
||||||
|
);
|
||||||
|
|
||||||
unsafe bool TryRemove(nuint key, uint hash, Bucket* bucket, out nuint value);
|
unsafe bool TryRemove(
|
||||||
|
nuint key,
|
||||||
|
uint hash,
|
||||||
|
Bucket* bucket,
|
||||||
|
out nuint value
|
||||||
|
);
|
||||||
|
|
||||||
bool TrySet(nuint key, uint hash, Bucket* bucket, nuint value, out bool isNewKey);
|
bool TrySet(
|
||||||
|
nuint key,
|
||||||
|
uint hash,
|
||||||
|
Bucket* bucket,
|
||||||
|
nuint value,
|
||||||
|
out bool isNewKey
|
||||||
|
);
|
||||||
|
|
||||||
private static IBucketScanner Create()
|
private static IBucketScanner Create()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="UnmanagedArray"
|
// file="UnmanagedArray"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="UnmanagedStack"
|
// file="UnmanagedStack"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -33,8 +13,11 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StgSharp.Collections
|
namespace StgSharp.Collections
|
||||||
{
|
{
|
||||||
public unsafe class UnmanagedStack<T>(T* address, int capacity, Action<nuint> freeHandle) : IDisposable
|
public unsafe class UnmanagedStack<T>(
|
||||||
where T: unmanaged
|
T* address,
|
||||||
|
int capacity,
|
||||||
|
Action<nuint> freeHandle
|
||||||
|
) : IDisposable where T : unmanaged
|
||||||
{
|
{
|
||||||
|
|
||||||
private T* _array = address;
|
private T* _array = address;
|
||||||
@@ -65,13 +48,17 @@ namespace StgSharp.Collections
|
|||||||
return _array[--_index];
|
return _array[--_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Push(T value)
|
public void Push(
|
||||||
|
T value
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_array[_index] = value;
|
_array[_index] = value;
|
||||||
_index++;
|
_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryPop(out T value)
|
public bool TryPop(
|
||||||
|
out T value
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (_index == 0)
|
if (_index == 0)
|
||||||
{
|
{
|
||||||
@@ -82,7 +69,9 @@ namespace StgSharp.Collections
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryPush(T value)
|
public bool TryPush(
|
||||||
|
T value
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (_index >= _capacity) {
|
if (_index >= _capacity) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="Dialogue"
|
// file="Dialogue"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="ErrorDefine"
|
// file="ErrorDefine"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -36,7 +16,10 @@ namespace StgSharp
|
|||||||
public class UniformEmptyReferenceException : Exception
|
public class UniformEmptyReferenceException : Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
public UniformEmptyReferenceException(string program, string name)
|
public UniformEmptyReferenceException(
|
||||||
|
string program,
|
||||||
|
string name
|
||||||
|
)
|
||||||
: base(
|
: base(
|
||||||
$"Location -1 returned when trying to find uniform {name} in shader program {program}") { }
|
$"Location -1 returned when trying to find uniform {name} in shader program {program}") { }
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
// file="GlobalSetting"
|
||||||
// file="GlobalSetting.cs"
|
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person
|
|
||||||
// obtaining a copy of this software and associated documentation
|
|
||||||
// files (the “Software”), to deal in the Software without restriction,
|
|
||||||
// including without limitation the rights to use, copy, modify, merge,
|
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
// and to permit persons to whom the Software is furnished to do so,
|
|
||||||
// subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and
|
|
||||||
// this permission notice shall be included in all copies
|
|
||||||
// or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
|
||||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
||||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
|
||||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -85,12 +62,10 @@ namespace StgSharp
|
|||||||
public static bool VSyncActivated
|
public static bool VSyncActivated
|
||||||
{
|
{
|
||||||
get => vsyncActivated;
|
get => vsyncActivated;
|
||||||
set
|
set =>
|
||||||
{
|
|
||||||
// GraphicFramework.glfwSwapInterval(value ? 1 : 0);
|
// GraphicFramework.glfwSwapInterval(value ? 1 : 0);
|
||||||
vsyncActivated = value;
|
vsyncActivated = value;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="IStaticModule"
|
// file="IStaticModule"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -50,7 +30,9 @@ namespace StgSharp
|
|||||||
/// The configuration profile supplied at registration time. Use <see
|
/// The configuration profile supplied at registration time. Use <see
|
||||||
/// cref="IModuleInitializeProfile.Empty" /> if no configuration is required.
|
/// cref="IModuleInitializeProfile.Empty" /> if no configuration is required.
|
||||||
/// </param>
|
/// </param>
|
||||||
void InitializeModule(IModuleInitializeProfile profile);
|
void InitializeModule(
|
||||||
|
IModuleInitializeProfile profile
|
||||||
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Releases all resources acquired during <see cref="InitializeModule" />. Implementations should
|
/// Releases all resources acquired during <see cref="InitializeModule" />. Implementations should
|
||||||
@@ -98,12 +80,18 @@ namespace StgSharp
|
|||||||
/// Initializes a new <see cref="ModuleDescriptor" /> using <see
|
/// Initializes a new <see cref="ModuleDescriptor" /> using <see
|
||||||
/// cref="IModuleInitializeProfile.Empty" /> as the profile.
|
/// cref="IModuleInitializeProfile.Empty" /> as the profile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ModuleDescriptor(IStaticModule module) : this(module, IModuleInitializeProfile.Empty) { }
|
public ModuleDescriptor(
|
||||||
|
IStaticModule module
|
||||||
|
)
|
||||||
|
: this(module, IModuleInitializeProfile.Empty) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new <see cref="ModuleDescriptor" /> with an explicit profile.
|
/// Initializes a new <see cref="ModuleDescriptor" /> with an explicit profile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ModuleDescriptor(IStaticModule module, IModuleInitializeProfile profile)
|
public ModuleDescriptor(
|
||||||
|
IStaticModule module,
|
||||||
|
IModuleInitializeProfile profile
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Module = module;
|
Module = module;
|
||||||
Profile = profile;
|
Profile = profile;
|
||||||
@@ -139,15 +127,17 @@ namespace StgSharp
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An ordered collection of modules to be initialized during application startup and
|
/// An ordered collection of modules to be initialized during application startup and
|
||||||
/// uninitialized on shutdown. Supports three registration strategies so that the <c>new()</c>
|
/// uninitialized on shutdown. Supports three registration strategies so that the <c> new()
|
||||||
/// generic constraint is never a hard requirement.
|
/// </c> generic constraint is never a hard requirement.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class ModuleToInitializeCollection : IEnumerable<IStaticModule>, IStaticModule
|
public sealed class ModuleToInitializeCollection : IEnumerable<IStaticModule>, IStaticModule
|
||||||
{
|
{
|
||||||
|
|
||||||
private readonly List<ModuleDescriptor> _descriptors = [];
|
private readonly List<ModuleDescriptor> _descriptors = [];
|
||||||
|
|
||||||
internal ModuleToInitializeCollection(World.Initializer i)
|
internal ModuleToInitializeCollection(
|
||||||
|
World.Initializer i
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_descriptors.Add(new ModuleDescriptor(i));
|
_descriptors.Add(new ModuleDescriptor(i));
|
||||||
}
|
}
|
||||||
@@ -202,8 +192,9 @@ namespace StgSharp
|
|||||||
/// Optional initialization profile. Defaults to <see
|
/// Optional initialization profile. Defaults to <see
|
||||||
/// cref="IModuleInitializeProfile.Empty" /> when <see langword="null" />.
|
/// cref="IModuleInitializeProfile.Empty" /> when <see langword="null" />.
|
||||||
/// </param>
|
/// </param>
|
||||||
public ModuleToInitializeCollection UseModule<T>(IModuleInitializeProfile? profile = null)
|
public ModuleToInitializeCollection UseModule<T>(
|
||||||
where T: IStaticModule, new()
|
IModuleInitializeProfile? profile = null
|
||||||
|
) where T : IStaticModule, new()
|
||||||
{
|
{
|
||||||
return UseModule(static() => new T(), profile);
|
return UseModule(static() => new T(), profile);
|
||||||
}
|
}
|
||||||
@@ -225,7 +216,8 @@ namespace StgSharp
|
|||||||
/// </param>
|
/// </param>
|
||||||
public ModuleToInitializeCollection UseModule(
|
public ModuleToInitializeCollection UseModule(
|
||||||
Func<IStaticModule> factory,
|
Func<IStaticModule> factory,
|
||||||
IModuleInitializeProfile? profile = null)
|
IModuleInitializeProfile? profile = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (factory is null) {
|
if (factory is null) {
|
||||||
return this;
|
return this;
|
||||||
@@ -251,7 +243,10 @@ namespace StgSharp
|
|||||||
/// Optional initialization profile. Defaults to <see
|
/// Optional initialization profile. Defaults to <see
|
||||||
/// cref="IModuleInitializeProfile.Empty" /> when <see langword="null" />.
|
/// cref="IModuleInitializeProfile.Empty" /> when <see langword="null" />.
|
||||||
/// </param>
|
/// </param>
|
||||||
public ModuleToInitializeCollection UseModule(IStaticModule module, IModuleInitializeProfile? profile = null)
|
public ModuleToInitializeCollection UseModule(
|
||||||
|
IStaticModule module,
|
||||||
|
IModuleInitializeProfile? profile = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_descriptors.Add(new ModuleDescriptor(
|
_descriptors.Add(new ModuleDescriptor(
|
||||||
module,
|
module,
|
||||||
@@ -272,7 +267,9 @@ namespace StgSharp
|
|||||||
/// cref="InitializeModule()" />, ignoring the supplied profile because each contained module uses
|
/// cref="InitializeModule()" />, ignoring the supplied profile because each contained module uses
|
||||||
/// its own registered profile.
|
/// its own registered profile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void IStaticModule.InitializeModule(IModuleInitializeProfile profile)
|
void IStaticModule.InitializeModule(
|
||||||
|
IModuleInitializeProfile profile
|
||||||
|
)
|
||||||
{
|
{
|
||||||
InitializeModule();
|
InitializeModule();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="Platform"
|
// file="Platform"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.HighPerformance;
|
using StgSharp.HighPerformance;
|
||||||
using StgSharp.HighPerformance.ProcessorAbstraction;
|
using StgSharp.HighPerformance.ProcessorAbstraction;
|
||||||
using System;
|
using System;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="Global"
|
// file="Global"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
global using StgSharp.Internal;
|
global using StgSharp.Internal;
|
||||||
|
|
||||||
global using System;
|
global using System;
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
using System;
|
// -----------------------------------------------------------------------------
|
||||||
|
// file="IdMultiplexer"
|
||||||
|
// Project: StgSharp
|
||||||
|
// Copyright (c) Nitload.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -6,8 +13,5 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StgSharp.HighPerformance
|
namespace StgSharp.HighPerformance
|
||||||
{
|
{
|
||||||
public class IdMultiplexer
|
public class IdMultiplexer { }
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="BufferStack"
|
// file="BufferStack"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -32,24 +12,22 @@ using System.Runtime.InteropServices;
|
|||||||
namespace StgSharp.HighPerformance.Memory
|
namespace StgSharp.HighPerformance.Memory
|
||||||
{
|
{
|
||||||
[CollectionBuilder(typeof(BufferStackBuilder), nameof(BufferStackBuilder.Create))]
|
[CollectionBuilder(typeof(BufferStackBuilder), nameof(BufferStackBuilder.Create))]
|
||||||
public unsafe class BufferStack<T> : IDisposable where T: unmanaged
|
public unsafe class BufferStack<T> : IDisposable where T : unmanaged
|
||||||
{
|
{
|
||||||
|
|
||||||
private byte* _buffer;
|
private byte* _buffer;
|
||||||
private ulong _count;
|
private ulong _count;
|
||||||
|
|
||||||
public BufferStack(int capacity)
|
public BufferStack(
|
||||||
|
int capacity
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(capacity);
|
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(capacity);
|
||||||
|
|
||||||
AllocateBuffer(capacity);
|
AllocateBuffer(capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Count
|
public int Count => (int)_count;
|
||||||
{
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
get => (int)_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Clear()
|
public void Clear()
|
||||||
@@ -79,7 +57,9 @@ namespace StgSharp.HighPerformance.Memory
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Push(T item)
|
public void Push(
|
||||||
|
T item
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Header* header = (Header*)_buffer;
|
Header* header = (Header*)_buffer;
|
||||||
if (header->Top >= header->Capacity)
|
if (header->Top >= header->Capacity)
|
||||||
@@ -95,7 +75,9 @@ namespace StgSharp.HighPerformance.Memory
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool TryPop(out T value)
|
public bool TryPop(
|
||||||
|
out T value
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Header* header = (Header*)_buffer;
|
Header* header = (Header*)_buffer;
|
||||||
if (header->Top == 0)
|
if (header->Top == 0)
|
||||||
@@ -112,7 +94,9 @@ namespace StgSharp.HighPerformance.Memory
|
|||||||
|
|
||||||
// Internal method for efficient bulk initialization
|
// Internal method for efficient bulk initialization
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal unsafe void InitializeFromSpan(ReadOnlySpan<T> span)
|
internal unsafe void InitializeFromSpan(
|
||||||
|
ReadOnlySpan<T> span
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (span.IsEmpty) {
|
if (span.IsEmpty) {
|
||||||
return;
|
return;
|
||||||
@@ -131,7 +115,9 @@ namespace StgSharp.HighPerformance.Memory
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void AllocateBuffer(int capacity)
|
private void AllocateBuffer(
|
||||||
|
int capacity
|
||||||
|
)
|
||||||
{
|
{
|
||||||
nuint size = (nuint)sizeof(Header) + ((nuint)capacity * (nuint)sizeof(T));
|
nuint size = (nuint)sizeof(Header) + ((nuint)capacity * (nuint)sizeof(T));
|
||||||
_buffer = (byte*)NativeMemory.Alloc(size);
|
_buffer = (byte*)NativeMemory.Alloc(size);
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="ConcurrentBufferStack"
|
// file="ConcurrentBufferStack"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Threading;
|
using StgSharp.Threading;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="L4.CacheLine"
|
// file="L4.CacheLine"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.HighPerformance.ProcessorAbstraction;
|
using StgSharp.HighPerformance.ProcessorAbstraction;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="L4.Debug"
|
// file="L4.Debug"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="L4.Evict"
|
// file="L4.Evict"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
namespace StgSharp.HighPerformance.Memory
|
namespace StgSharp.HighPerformance.Memory
|
||||||
{
|
{
|
||||||
public partial class L4
|
public partial class L4
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="L4.Exceptions"
|
// file="L4.Exceptions"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
namespace StgSharp.HighPerformance.Memory
|
namespace StgSharp.HighPerformance.Memory
|
||||||
{
|
{
|
||||||
#pragma warning disable CA1032 // Implement standard exception constructors
|
#pragma warning disable CA1032 // Implement standard exception constructors
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="L4.Predict"
|
// file="L4.Predict"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Collections;
|
using StgSharp.Collections;
|
||||||
using StgSharp.HighPerformance.Memory;
|
using StgSharp.HighPerformance.Memory;
|
||||||
using System;
|
using System;
|
||||||
@@ -41,7 +21,9 @@ namespace StgSharp.HighPerformance.Memory
|
|||||||
|
|
||||||
private IL4Predict CurrentPredict { get; set; }
|
private IL4Predict CurrentPredict { get; set; }
|
||||||
|
|
||||||
public void ResetPredict(IL4Predict predict)
|
public void ResetPredict(
|
||||||
|
IL4Predict predict
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (CurrentPredict is null)
|
if (CurrentPredict is null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="L4.Predictor"
|
// file="L4.Predictor"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="L4.Prefetch"
|
// file="L4.Prefetch"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="L4.Tlsf"
|
// file="L4.Tlsf"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.HighPerformance.ProcessorAbstraction;
|
using StgSharp.HighPerformance.ProcessorAbstraction;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="L4"
|
// file="L4"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Collections;
|
using StgSharp.Collections;
|
||||||
using StgSharp.HighPerformance.Memory;
|
using StgSharp.HighPerformance.Memory;
|
||||||
using StgSharp.HighPerformance.ProcessorAbstraction;
|
using StgSharp.HighPerformance.ProcessorAbstraction;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="Ptr64"
|
// file="Ptr64"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="SlabAllocationHandle"
|
// file="SlabAllocationHandle"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="SlabAllocator.Chunked"
|
// file="SlabAllocator.Chunked"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Threading;
|
using StgSharp.Threading;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="SlabAllocator.ChunkedConcurrent"
|
// file="SlabAllocator.ChunkedConcurrent"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Threading;
|
using StgSharp.Threading;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@@ -38,7 +18,8 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StgSharp.HighPerformance.Memory
|
namespace StgSharp.HighPerformance.Memory
|
||||||
{
|
{
|
||||||
internal sealed unsafe class ConcurrentChunkedSlabAllocator<T> : SlabAllocator<T> where T: unmanaged
|
internal sealed unsafe class ConcurrentChunkedSlabAllocator<T> : SlabAllocator<T>
|
||||||
|
where T : unmanaged
|
||||||
{
|
{
|
||||||
|
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
@@ -51,7 +32,9 @@ namespace StgSharp.HighPerformance.Memory
|
|||||||
private nuint _currentBuffer;
|
private nuint _currentBuffer;
|
||||||
private nuint _currentCapacity, _currentIndex;
|
private nuint _currentCapacity, _currentIndex;
|
||||||
|
|
||||||
public ConcurrentChunkedSlabAllocator(nuint count)
|
public ConcurrentChunkedSlabAllocator(
|
||||||
|
nuint count
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_currentBuffer = (nuint)NativeMemory.Alloc(count * (nuint)_elementSize);
|
_currentBuffer = (nuint)NativeMemory.Alloc(count * (nuint)_elementSize);
|
||||||
_currentCapacity = count;
|
_currentCapacity = count;
|
||||||
@@ -137,7 +120,9 @@ namespace StgSharp.HighPerformance.Memory
|
|||||||
public override void ExitBufferReading() { }
|
public override void ExitBufferReading() { }
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public override void Free(nuint index)
|
public override void Free(
|
||||||
|
nuint index
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_recycle.Push(index);
|
_recycle.Push(index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="SlabAllocator.Fixed"
|
// file="SlabAllocator.Fixed"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Collections;
|
using StgSharp.Collections;
|
||||||
using StgSharp.HighPerformance.Memory;
|
using StgSharp.HighPerformance.Memory;
|
||||||
using StgSharp.Threading;
|
using StgSharp.Threading;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="SlabAllocator.SequencialConcurrent"
|
// file="SlabAllocator.SequencialConcurrent"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Threading;
|
using StgSharp.Threading;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="SlabAllocator"
|
// file="SlabAllocator"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.HighPerformance.Memory;
|
using StgSharp.HighPerformance.Memory;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
@@ -55,26 +35,26 @@ namespace StgSharp.HighPerformance.Memory
|
|||||||
/// Thrown when requesting unsupported configurations.
|
/// Thrown when requesting unsupported configurations.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para><strong> Important Threading Considerations: </strong></para> <para> While SLAB
|
/// <para><strong> Important Threading Considerations: </strong></para> <para>While SLAB
|
||||||
/// allocators themselves may be designed for single-threaded use, allocated objects are
|
/// allocators themselves may be designed for single-threaded use, allocated objects are
|
||||||
/// frequently shared across multiple threads in real-world applications. Due to the
|
/// frequently shared across multiple threads in real-world applications. Due to the
|
||||||
/// special implementation of expandable concurrent sequential SLAB allocators, they rely
|
/// special implementation of expandable concurrent sequential SLAB allocators, they rely
|
||||||
/// on internal expansion locks to ensure that memory buffer expansions (which involve
|
/// on internal expansion locks to ensure that memory buffer expansions (which involve
|
||||||
/// copying the entire buffer to a new location) do not occur while other threads are
|
/// copying the entire buffer to a new location) do not occur while other threads are
|
||||||
/// reading from allocated regions.</para> <para><strong>Sequential Layout
|
/// reading from allocated regions. </para> <para><strong> Sequential Layout Limitations:
|
||||||
/// Limitations:</strong><br /> Sequential layout SLAB allocators cannot provide a single-
|
/// </strong><br /> Sequential layout SLAB allocators cannot provide a single- threaded
|
||||||
/// threaded version because:<list type="bullet"><item><description>They use contiguous
|
/// version because:<list type="bullet"><item><description> They use contiguous memory
|
||||||
/// memory layout that requires buffer expansion when capacity is
|
/// layout that requires buffer expansion when capacity is exceeded
|
||||||
/// exceeded</description></item><item><description>Buffer expansion involves copying all
|
/// </description></item><item><description> Buffer expansion involves copying all
|
||||||
/// existing data to a new memory location</description></item><item><description> Without
|
/// existing data to a new memory location </description></item><item><description>Without
|
||||||
/// proper synchronization, concurrent access to allocated objects during synchronization,
|
/// proper synchronization, concurrent access to allocated objects during synchronization,
|
||||||
/// concurrent access to allocated objects during expansion would cause memory corruption
|
/// concurrent access to allocated objects during expansion would cause memory
|
||||||
/// </description></item><item><description> The expansion lock mechanism is essential
|
/// corruption</description></item><item><description>The expansion lock mechanism is
|
||||||
/// even if allocation itself is single- threaded</description></item></list></para>
|
/// essential even if allocation itself is single- threaded
|
||||||
/// <para><strong> Chunked Layout: </strong><br /> Chunked layout allocators can
|
/// </description></item></list></para> <para><strong> Chunked Layout: </strong><br />
|
||||||
/// optionally provide single-threaded versions since they don't require buffer expansion
|
/// Chunked layout allocators can optionally provide single-threaded versions since they
|
||||||
/// and copying. Each chunk is allocated independently, avoiding the memory relocation
|
/// don't require buffer expansion and copying. Each chunk is allocated independently,
|
||||||
/// issues present in sequential layouts.</para>
|
/// avoiding the memory relocation issues present in sequential layouts. </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static SlabAllocator<T> Create<T>(
|
public static SlabAllocator<T> Create<T>(
|
||||||
nuint count,
|
nuint count,
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="TwoLayerSegregatedFitAllocator"
|
// file="TwoLayerSegregatedFitAllocator"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.HighPerformance.Memory;
|
using StgSharp.HighPerformance.Memory;
|
||||||
using StgSharp.HighPerformance.ProcessorAbstraction;
|
using StgSharp.HighPerformance.ProcessorAbstraction;
|
||||||
using System;
|
using System;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="IRegisterType"
|
// file="IRegisterType"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -59,7 +39,7 @@ namespace StgSharp.HighPerformance.ProcessorAbstraction
|
|||||||
/// cref="Member{T}(int)" /> with index 0. Caller must choose a type layout compatible with the
|
/// cref="Member{T}(int)" /> with index 0. Caller must choose a type layout compatible with the
|
||||||
/// actual register representation.
|
/// actual register representation.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
ref T AsRef<T>() where T: unmanaged, INumber<T>;
|
ref T AsRef<T>() where T : unmanaged, INumber<T>;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fills all elements (lanes) of the register with the provided scalar <paramref name="value" />.
|
/// Fills all elements (lanes) of the register with the provided scalar <paramref name="value" />.
|
||||||
@@ -74,7 +54,9 @@ namespace StgSharp.HighPerformance.ProcessorAbstraction
|
|||||||
/// Should map to a single broadcast/shuffle instruction where possible. After completion all
|
/// Should map to a single broadcast/shuffle instruction where possible. After completion all
|
||||||
/// lanes read back the same value.
|
/// lanes read back the same value.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
void BroadCastFrom<T>(T value) where T: unmanaged, INumber<T>;
|
void BroadCastFrom<T>(
|
||||||
|
T value
|
||||||
|
) where T : unmanaged, INumber<T>;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a writable reference to the element at the specified <paramref name="index" />.
|
/// Gets a writable reference to the element at the specified <paramref name="index" />.
|
||||||
@@ -92,7 +74,9 @@ namespace StgSharp.HighPerformance.ProcessorAbstraction
|
|||||||
/// Enables scalar lane edits without unpacking the entire register. Implementations may omit
|
/// Enables scalar lane edits without unpacking the entire register. Implementations may omit
|
||||||
/// bounds checks for performance. Caller is responsible for passing a valid index.
|
/// bounds checks for performance. Caller is responsible for passing a valid index.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
ref T Member<T>(int index) where T: unmanaged, INumber<T>;
|
ref T Member<T>(
|
||||||
|
int index
|
||||||
|
) where T : unmanaged, INumber<T>;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="LogicalCore"
|
// file="LogicalCore"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="M128"
|
// file="M128"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
@@ -45,20 +25,24 @@ namespace StgSharp.HighPerformance.ProcessorAbstraction
|
|||||||
[FieldOffset(0)] internal fixed byte Buffer[16];
|
[FieldOffset(0)] internal fixed byte Buffer[16];
|
||||||
[FieldOffset(0)] internal Vector128<float> Vec;
|
[FieldOffset(0)] internal Vector128<float> Vec;
|
||||||
|
|
||||||
internal M128(Vector4 v)
|
internal M128(
|
||||||
|
Vector4 v
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Unsafe.SkipInit(out this);
|
Unsafe.SkipInit(out this);
|
||||||
Unsafe.SkipInit(out Vec);
|
Unsafe.SkipInit(out Vec);
|
||||||
Vec = v.AsVector128();
|
Vec = v.AsVector128();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal M128(Vector128<float> v)
|
internal M128(
|
||||||
|
Vector128<float> v
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Unsafe.SkipInit(out this);
|
Unsafe.SkipInit(out this);
|
||||||
Vec = v;
|
Vec = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ref T AsRef<T>() where T: unmanaged, INumber<T>
|
public ref T AsRef<T>() where T : unmanaged, INumber<T>
|
||||||
{
|
{
|
||||||
return ref Unsafe.As<byte, T>(ref Buffer[0]);
|
return ref Unsafe.As<byte, T>(ref Buffer[0]);
|
||||||
}
|
}
|
||||||
@@ -69,12 +53,16 @@ namespace StgSharp.HighPerformance.ProcessorAbstraction
|
|||||||
return Vec.AsVector4();
|
return Vec.AsVector4();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BroadCastFrom<T>(T value) where T: unmanaged, INumber<T>
|
public void BroadCastFrom<T>(
|
||||||
|
T value
|
||||||
|
) where T : unmanaged, INumber<T>
|
||||||
{
|
{
|
||||||
Vec = Vector128.Create<T>(value).AsSingle();
|
Vec = Vector128.Create<T>(value).AsSingle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override readonly bool Equals([NotNullWhen(true)] object obj)
|
public override readonly bool Equals(
|
||||||
|
[NotNullWhen(true)] object obj
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return obj is M128 other && this == other;
|
return obj is M128 other && this == other;
|
||||||
}
|
}
|
||||||
@@ -85,7 +73,9 @@ namespace StgSharp.HighPerformance.ProcessorAbstraction
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ref T Member<T>(int index) where T: unmanaged, INumber<T>
|
public ref T Member<T>(
|
||||||
|
int index
|
||||||
|
) where T : unmanaged, INumber<T>
|
||||||
{
|
{
|
||||||
return ref Unsafe.Add(ref AsRef<T>(), index);
|
return ref Unsafe.Add(ref AsRef<T>(), index);
|
||||||
}
|
}
|
||||||
@@ -95,7 +85,9 @@ namespace StgSharp.HighPerformance.ProcessorAbstraction
|
|||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ToString(int sample)
|
public string ToString(
|
||||||
|
int sample
|
||||||
|
)
|
||||||
{
|
{
|
||||||
string str = string.Empty;
|
string str = string.Empty;
|
||||||
for (int i = 15; i >= 0; i--) {
|
for (int i = 15; i >= 0; i--) {
|
||||||
@@ -105,13 +97,19 @@ namespace StgSharp.HighPerformance.ProcessorAbstraction
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static bool operator !=(M128 left, M128 right)
|
public static bool operator !=(
|
||||||
|
M128 left,
|
||||||
|
M128 right
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return left.Vec != right.Vec;
|
return left.Vec != right.Vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static bool operator ==(M128 left, M128 right)
|
public static bool operator ==(
|
||||||
|
M128 left,
|
||||||
|
M128 right
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return left.Vec == right.Vec;
|
return left.Vec == right.Vec;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="M256"
|
// file="M256"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -45,18 +25,22 @@ namespace StgSharp.HighPerformance.ProcessorAbstraction
|
|||||||
[FieldOffset(0)] internal Vector256<float> Vec;
|
[FieldOffset(0)] internal Vector256<float> Vec;
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ref T AsRef<T>() where T: unmanaged, INumber<T>
|
public ref T AsRef<T>() where T : unmanaged, INumber<T>
|
||||||
{
|
{
|
||||||
return ref Unsafe.As<byte, T>(ref Buffer[0]);
|
return ref Unsafe.As<byte, T>(ref Buffer[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BroadCastFrom<T>(T value) where T: unmanaged, INumber<T>
|
public void BroadCastFrom<T>(
|
||||||
|
T value
|
||||||
|
) where T : unmanaged, INumber<T>
|
||||||
{
|
{
|
||||||
Vec = Vector256.Create(value).AsSingle();
|
Vec = Vector256.Create(value).AsSingle();
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ref T Member<T>(int index) where T: unmanaged, INumber<T>
|
public ref T Member<T>(
|
||||||
|
int index
|
||||||
|
) where T : unmanaged, INumber<T>
|
||||||
{
|
{
|
||||||
return ref Unsafe.Add(ref AsRef<T>(), index);
|
return ref Unsafe.Add(ref AsRef<T>(), index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="M512"
|
// file="M512"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="M64"
|
// file="M64"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="Numa"
|
// file="Numa"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.HighPerformance.Memory;
|
using StgSharp.HighPerformance.Memory;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="NumaNode"
|
// file="NumaNode"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="DefaultLog"
|
// file="DefaultLog"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="Native"
|
// file="Native"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="public"
|
// file="public"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="CrossFramePipelineNode"
|
// file="CrossFramePipelineNode"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.PipeLine;
|
using StgSharp.PipeLine;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@@ -38,13 +18,16 @@ namespace StgSharp.PipeLine
|
|||||||
public class CrossFrameOperation : IConvertableToPipelineNode
|
public class CrossFrameOperation : IConvertableToPipelineNode
|
||||||
{
|
{
|
||||||
|
|
||||||
private static string[] _inputName = [ "TaskIn" ];
|
private static string[] _inputName = ["TaskIn"];
|
||||||
private static string[] _outputName = [ "TaskOut" ];
|
private static string[] _outputName = ["TaskOut"];
|
||||||
private Action _mainExecution;
|
private Action _mainExecution;
|
||||||
private int currentCount;
|
private int currentCount;
|
||||||
private readonly int cycleCount;
|
private readonly int cycleCount;
|
||||||
|
|
||||||
public CrossFrameOperation(Action startup, int cycleCount)
|
public CrossFrameOperation(
|
||||||
|
Action startup,
|
||||||
|
int cycleCount
|
||||||
|
)
|
||||||
{
|
{
|
||||||
MainExecution = startup;
|
MainExecution = startup;
|
||||||
this.cycleCount = (cycleCount > 1) ?
|
this.cycleCount = (cycleCount > 1) ?
|
||||||
@@ -65,14 +48,12 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
public IEnumerable<string> OutputPortName => _outputName;
|
public IEnumerable<string> OutputPortName => _outputName;
|
||||||
|
|
||||||
public PipelineNodeOperation Operation
|
public PipelineNodeOperation Operation => NodeMain;
|
||||||
{
|
|
||||||
get => NodeMain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void NodeMain(
|
public void NodeMain(
|
||||||
in Dictionary<string, PipelineNodeInPort> input,
|
in Dictionary<string, PipelineNodeInPort> input,
|
||||||
in Dictionary<string, PipelineNodeOutPort> output)
|
in Dictionary<string, PipelineNodeOutPort> output
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (currentCount < cycleCount)
|
if (currentCount < cycleCount)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="IConvertableToPipelineNode"
|
// file="IConvertableToPipelineNode"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
@@ -34,7 +14,8 @@ namespace StgSharp.PipeLine
|
|||||||
{
|
{
|
||||||
public delegate void PipelineNodeOperation(
|
public delegate void PipelineNodeOperation(
|
||||||
in Dictionary<string, PipelineNodeInPort> input,
|
in Dictionary<string, PipelineNodeInPort> input,
|
||||||
in Dictionary<string, PipelineNodeOutPort> output);
|
in Dictionary<string, PipelineNodeOutPort> output
|
||||||
|
);
|
||||||
|
|
||||||
public interface IConvertableToPipelineNode
|
public interface IConvertableToPipelineNode
|
||||||
{
|
{
|
||||||
@@ -47,7 +28,8 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
void NodeMain(
|
void NodeMain(
|
||||||
in Dictionary<string, PipelineNodeInPort> input,
|
in Dictionary<string, PipelineNodeInPort> input,
|
||||||
in Dictionary<string, PipelineNodeOutPort> output);
|
in Dictionary<string, PipelineNodeOutPort> output
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +40,11 @@ namespace StgSharp.PipeLine
|
|||||||
private string[] _output;
|
private string[] _output;
|
||||||
private PipelineNodeOperation _execution;
|
private PipelineNodeOperation _execution;
|
||||||
|
|
||||||
public DefaultConvertableToBlueprintNode(PipelineNodeOperation execution, string[] input, string[] output)
|
public DefaultConvertableToBlueprintNode(
|
||||||
|
PipelineNodeOperation execution,
|
||||||
|
string[] input,
|
||||||
|
string[] output
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_input = input;
|
_input = input;
|
||||||
_output = output;
|
_output = output;
|
||||||
@@ -73,7 +59,8 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
public void NodeMain(
|
public void NodeMain(
|
||||||
in Dictionary<string, PipelineNodeInPort> input,
|
in Dictionary<string, PipelineNodeInPort> input,
|
||||||
in Dictionary<string, PipelineNodeOutPort> output)
|
in Dictionary<string, PipelineNodeOutPort> output
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_execution.Invoke(input, output);
|
_execution.Invoke(input, output);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="PipeLineRunner"
|
// file="PipeLineRunner"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Threading;
|
using StgSharp.Threading;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@@ -50,7 +30,9 @@ namespace StgSharp.PipeLine
|
|||||||
private static int _callingThread;
|
private static int _callingThread;
|
||||||
private static SemaphoreSlim pipelineLock = new SemaphoreSlim(0, 1);
|
private static SemaphoreSlim pipelineLock = new SemaphoreSlim(0, 1);
|
||||||
|
|
||||||
public static void Run(PipelineScheduler pipeline)
|
public static void Run(
|
||||||
|
PipelineScheduler pipeline
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Console.WriteLine();
|
// Console.WriteLine();
|
||||||
if (pipeline == null)
|
if (pipeline == null)
|
||||||
@@ -71,7 +53,9 @@ namespace StgSharp.PipeLine
|
|||||||
Interlocked.Exchange(ref _callingThread, -1);
|
Interlocked.Exchange(ref _callingThread, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetMaxTaskCount(int size)
|
public static void SetMaxTaskCount(
|
||||||
|
int size
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (size < 1) {
|
if (size < 1) {
|
||||||
size = 1;
|
size = 1;
|
||||||
@@ -104,7 +88,9 @@ namespace StgSharp.PipeLine
|
|||||||
pipelineInWaiting.Clear();
|
pipelineInWaiting.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool InterruptAndRunNewPipeline(PipelineScheduler newPipeline)
|
internal static bool InterruptAndRunNewPipeline(
|
||||||
|
PipelineScheduler newPipeline
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(newPipeline);
|
ArgumentNullException.ThrowIfNull(newPipeline);
|
||||||
if ((newPipeline != NodeRunner.CurrentPipeline) && (NodeRunner.CurrentPipeline != null))
|
if ((newPipeline != NodeRunner.CurrentPipeline) && (NodeRunner.CurrentPipeline != null))
|
||||||
@@ -134,7 +120,8 @@ namespace StgSharp.PipeLine
|
|||||||
}
|
}
|
||||||
/**/
|
/**/
|
||||||
PipelineNode node;
|
PipelineNode node;
|
||||||
while (!cts.Token.IsCancellationRequested && NodeRunner.CurrentPipeline.RequestNextMainThreadNode(out node))
|
while (!cts.Token.IsCancellationRequested &&
|
||||||
|
NodeRunner.CurrentPipeline.RequestNextMainThreadNode(out node))
|
||||||
{
|
{
|
||||||
node.Run();
|
node.Run();
|
||||||
if (!NodeRunner.CurrentPipeline.IsRunning)
|
if (!NodeRunner.CurrentPipeline.IsRunning)
|
||||||
@@ -161,9 +148,9 @@ namespace StgSharp.PipeLine
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para> Only the following occasions of calling are valid: </para> <para> 1. no bp is
|
/// <para> Only the following occasions of calling are valid: </para> <para>1. no bp is
|
||||||
/// running or the only bp is quitting. </para><para> 2. calling from the main thread or a
|
/// running or the only bp is quitting.</para><para>2. calling from the main thread or a
|
||||||
/// thread the current bp is running on.</para>
|
/// thread the current bp is running on. </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static bool IsValidCalling()
|
internal static bool IsValidCalling()
|
||||||
{
|
{
|
||||||
@@ -226,7 +213,9 @@ namespace StgSharp.PipeLine
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void InternalRun(CancellationToken token)
|
private static void InternalRun(
|
||||||
|
CancellationToken token
|
||||||
|
)
|
||||||
{
|
{
|
||||||
PipelineNode item;
|
PipelineNode item;
|
||||||
Console.WriteLine($"Global thread {Environment.CurrentManagedThreadId} starts.");
|
Console.WriteLine($"Global thread {Environment.CurrentManagedThreadId} starts.");
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="PipelineMarshal"
|
// file="PipelineMarshal"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -38,7 +18,9 @@ namespace StgSharp.PipeLine
|
|||||||
public static class PipelineMarshal
|
public static class PipelineMarshal
|
||||||
{
|
{
|
||||||
|
|
||||||
public static IEnumerable<PipelineNode> GetNodeSortedEnumeration(PipelineScheduler scheduler)
|
public static IEnumerable<PipelineNode> GetNodeSortedEnumeration(
|
||||||
|
PipelineScheduler scheduler
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(scheduler);
|
ArgumentNullException.ThrowIfNull(scheduler);
|
||||||
return new PipelineNodeEnumerator(scheduler)
|
return new PipelineNodeEnumerator(scheduler)
|
||||||
@@ -54,7 +36,9 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
public int _count;
|
public int _count;
|
||||||
|
|
||||||
public PipelineNodeEnumerator(PipelineScheduler scheduler)
|
public PipelineNodeEnumerator(
|
||||||
|
PipelineScheduler scheduler
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!scheduler.TryGetAllNode(out _mt, out _c)) {
|
if (!scheduler.TryGetAllNode(out _mt, out _c)) {
|
||||||
throw new InvalidOperationException("Binded scheduler is not sorted.");
|
throw new InvalidOperationException("Binded scheduler is not sorted.");
|
||||||
@@ -78,7 +62,9 @@ namespace StgSharp.PipeLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollection<PipelineNode>.Add(PipelineNode item)
|
void ICollection<PipelineNode>.Add(
|
||||||
|
PipelineNode item
|
||||||
|
)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
@@ -88,17 +74,24 @@ namespace StgSharp.PipeLine
|
|||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ICollection<PipelineNode>.Contains(PipelineNode item)
|
bool ICollection<PipelineNode>.Contains(
|
||||||
|
PipelineNode item
|
||||||
|
)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollection<PipelineNode>.CopyTo(PipelineNode[] array, int arrayIndex)
|
void ICollection<PipelineNode>.CopyTo(
|
||||||
|
PipelineNode[] array,
|
||||||
|
int arrayIndex
|
||||||
|
)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ICollection<PipelineNode>.Remove(PipelineNode item)
|
bool ICollection<PipelineNode>.Remove(
|
||||||
|
PipelineNode item
|
||||||
|
)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,9 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="PipelineNode"
|
// file="PipelineNode"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -61,7 +40,11 @@ namespace StgSharp.PipeLine
|
|||||||
private protected Dictionary<string, PipelineNodeOutPort> _output;
|
private protected Dictionary<string, PipelineNodeOutPort> _output;
|
||||||
private protected int _level, _count;
|
private protected int _level, _count;
|
||||||
|
|
||||||
internal PipelineNode(PipelineNodeLabel label, IConvertableToPipelineNode node, bool isNative)
|
internal PipelineNode(
|
||||||
|
PipelineNodeLabel label,
|
||||||
|
IConvertableToPipelineNode node,
|
||||||
|
bool isNative
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_label = label;
|
_label = label;
|
||||||
_nativeRequested = isNative;
|
_nativeRequested = isNative;
|
||||||
@@ -82,7 +65,8 @@ namespace StgSharp.PipeLine
|
|||||||
PipelineNodeLabel name,
|
PipelineNodeLabel name,
|
||||||
bool isNative,
|
bool isNative,
|
||||||
string[] inputNames,
|
string[] inputNames,
|
||||||
string[] outputNames)
|
string[] outputNames
|
||||||
|
)
|
||||||
#pragma warning restore CS8618
|
#pragma warning restore CS8618
|
||||||
{
|
{
|
||||||
if ((inputNames == null) || (inputNames.Length == 0)) {
|
if ((inputNames == null) || (inputNames.Length == 0)) {
|
||||||
@@ -148,7 +132,12 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
internal int RemainingIncreaseCount => Previous.Count - _count;
|
internal int RemainingIncreaseCount => Previous.Count - _count;
|
||||||
|
|
||||||
public static void Connect(PipelineNode front, string frontNodePort, string backNodePort, PipelineNode back)
|
public static void Connect(
|
||||||
|
PipelineNode front,
|
||||||
|
string frontNodePort,
|
||||||
|
string backNodePort,
|
||||||
|
PipelineNode back
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(front);
|
ArgumentNullException.ThrowIfNull(front);
|
||||||
ArgumentNullException.ThrowIfNull(back);
|
ArgumentNullException.ThrowIfNull(back);
|
||||||
@@ -191,7 +180,9 @@ namespace StgSharp.PipeLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool TryIncreaseLevelTo(int level)
|
internal bool TryIncreaseLevelTo(
|
||||||
|
int level
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
if (_count > Previous.Count) {
|
if (_count > Previous.Count) {
|
||||||
@@ -203,14 +194,17 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
protected static void DefaultOperation(
|
protected static void DefaultOperation(
|
||||||
in Dictionary<string, PipelineNodeInPort> input,
|
in Dictionary<string, PipelineNodeInPort> input,
|
||||||
in Dictionary<string, PipelineNodeOutPort> output)
|
in Dictionary<string, PipelineNodeOutPort> output
|
||||||
|
)
|
||||||
{
|
{
|
||||||
PipelineNodeOutPort.SkipAll(output);
|
PipelineNodeOutPort.SkipAll(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region port operation
|
#region port operation
|
||||||
|
|
||||||
public PipelineNodeInPort GetInputPort(string lable)
|
public PipelineNodeInPort GetInputPort(
|
||||||
|
string lable
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!InputPorts.TryGetValue(lable, out PipelineNodeInPort? ret)) {
|
if (!InputPorts.TryGetValue(lable, out PipelineNodeInPort? ret)) {
|
||||||
throw new ArgumentOutOfRangeException(
|
throw new ArgumentOutOfRangeException(
|
||||||
@@ -219,7 +213,9 @@ namespace StgSharp.PipeLine
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PipelineNodeOutPort GetOutputPort(string lable)
|
public PipelineNodeOutPort GetOutputPort(
|
||||||
|
string lable
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!OutputPorts.TryGetValue(lable, out PipelineNodeOutPort? ret)) {
|
if (!OutputPorts.TryGetValue(lable, out PipelineNodeOutPort? ret)) {
|
||||||
throw new ArgumentOutOfRangeException(
|
throw new ArgumentOutOfRangeException(
|
||||||
@@ -228,7 +224,9 @@ namespace StgSharp.PipeLine
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PipelineNodeInPort? DefineCertainInputPort(string label)
|
public PipelineNodeInPort? DefineCertainInputPort(
|
||||||
|
string label
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (InputPorts.ContainsKey(label)) {
|
if (InputPorts.ContainsKey(label)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -238,7 +236,9 @@ namespace StgSharp.PipeLine
|
|||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PipelineNodeOutPort? DefineCertainOutputPort(string label)
|
public PipelineNodeOutPort? DefineCertainOutputPort(
|
||||||
|
string label
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (OutputPorts.ContainsKey(label)) {
|
if (OutputPorts.ContainsKey(label)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -256,11 +256,21 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
public PipelineNodeRunException() { }
|
public PipelineNodeRunException() { }
|
||||||
|
|
||||||
public PipelineNodeRunException(Exception ex) : base(string.Empty, ex) { }
|
public PipelineNodeRunException(
|
||||||
|
Exception ex
|
||||||
|
)
|
||||||
|
: base(string.Empty, ex) { }
|
||||||
|
|
||||||
public PipelineNodeRunException(string message) : base(message) { }
|
public PipelineNodeRunException(
|
||||||
|
string message
|
||||||
|
)
|
||||||
|
: base(message) { }
|
||||||
|
|
||||||
public PipelineNodeRunException(string message, Exception innerException) : base(message, innerException) { }
|
public PipelineNodeRunException(
|
||||||
|
string message,
|
||||||
|
Exception innerException
|
||||||
|
)
|
||||||
|
: base(message, innerException) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="PipelineNodeLabel"
|
// file="PipelineNodeLabel"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
@@ -52,7 +32,9 @@ namespace StgSharp.PipeLine
|
|||||||
public record class PipelineNodeStringLabel : PipelineNodeLabel
|
public record class PipelineNodeStringLabel : PipelineNodeLabel
|
||||||
{
|
{
|
||||||
|
|
||||||
public PipelineNodeStringLabel(string name)
|
public PipelineNodeStringLabel(
|
||||||
|
string name
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="PipelineNodePort"
|
// file="PipelineNodePort"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -40,7 +20,10 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
private HashSet<PipelineNodeOutPort> _linkerSet = new HashSet<PipelineNodeOutPort>();
|
private HashSet<PipelineNodeOutPort> _linkerSet = new HashSet<PipelineNodeOutPort>();
|
||||||
|
|
||||||
public PipelineNodeInPort(PipelineNode container, string label)
|
public PipelineNodeInPort(
|
||||||
|
PipelineNode container,
|
||||||
|
string label
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Container = container;
|
Container = container;
|
||||||
Label = label;
|
Label = label;
|
||||||
@@ -56,7 +39,9 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
internal HashSet<PipelineNodeOutPort> Linkers => _linkerSet;
|
internal HashSet<PipelineNodeOutPort> Linkers => _linkerSet;
|
||||||
|
|
||||||
public void Connect(PipelineNodeOutPort port)
|
public void Connect(
|
||||||
|
PipelineNodeOutPort port
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(port);
|
ArgumentNullException.ThrowIfNull(port);
|
||||||
if (_linkerSet.Add(port))
|
if (_linkerSet.Add(port))
|
||||||
@@ -79,7 +64,9 @@ namespace StgSharp.PipeLine
|
|||||||
PipelineNodeOutPort.WaitAll(_linkerSet);
|
PipelineNodeOutPort.WaitAll(_linkerSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WaitAll(IDictionary<string, PipelineNodeInPort> ports)
|
public static void WaitAll(
|
||||||
|
IDictionary<string, PipelineNodeInPort> ports
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (ports is null) {
|
if (ports is null) {
|
||||||
return;
|
return;
|
||||||
@@ -89,7 +76,9 @@ namespace StgSharp.PipeLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WaitAll(IEnumerable<PipelineNodeInPort> ports)
|
public static void WaitAll(
|
||||||
|
IEnumerable<PipelineNodeInPort> ports
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (ports is null) {
|
if (ports is null) {
|
||||||
return;
|
return;
|
||||||
@@ -108,7 +97,10 @@ namespace StgSharp.PipeLine
|
|||||||
private volatile int _passCount;
|
private volatile int _passCount;
|
||||||
private SemaphoreSlim formerCompleteSemaphore;
|
private SemaphoreSlim formerCompleteSemaphore;
|
||||||
|
|
||||||
public PipelineNodeOutPort(PipelineNode container, string label)
|
public PipelineNodeOutPort(
|
||||||
|
PipelineNode container,
|
||||||
|
string label
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Container = container;
|
Container = container;
|
||||||
Label = label;
|
Label = label;
|
||||||
@@ -123,7 +115,9 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
private SemaphoreSlim Waiter => formerCompleteSemaphore;
|
private SemaphoreSlim Waiter => formerCompleteSemaphore;
|
||||||
|
|
||||||
public void Connect(PipelineNodeInPort port)
|
public void Connect(
|
||||||
|
PipelineNodeInPort port
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(port);
|
ArgumentNullException.ThrowIfNull(port);
|
||||||
if (_linkerSet.Add(port))
|
if (_linkerSet.Add(port))
|
||||||
@@ -145,7 +139,9 @@ namespace StgSharp.PipeLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SkipAll(Dictionary<string, PipelineNodeOutPort> ports)
|
public static void SkipAll(
|
||||||
|
Dictionary<string, PipelineNodeOutPort> ports
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (ports is null) {
|
if (ports is null) {
|
||||||
return;
|
return;
|
||||||
@@ -155,12 +151,16 @@ namespace StgSharp.PipeLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TransmitValue(IPipeLineConnectionPayload value)
|
public void TransmitValue(
|
||||||
|
IPipeLineConnectionPayload value
|
||||||
|
)
|
||||||
{
|
{
|
||||||
foreach (PipelineNodeInPort item in _linkerSet) { }
|
foreach (PipelineNodeInPort item in _linkerSet) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WaitAll(IEnumerable<PipelineNodeOutPort> ports)
|
public static void WaitAll(
|
||||||
|
IEnumerable<PipelineNodeOutPort> ports
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (ports is null) {
|
if (ports is null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="PipelineScheduler"
|
// file="PipelineScheduler"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
@@ -61,43 +41,30 @@ namespace StgSharp.PipeLine
|
|||||||
}
|
}
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
public PipelineNode this[PipelineNodeLabel label]
|
public PipelineNode this[
|
||||||
{
|
PipelineNodeLabel label
|
||||||
get { return _allNode[label]; }
|
] => _allNode[label];
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsRunning
|
public bool IsRunning => runningStat.CurrentCount == 0;
|
||||||
{
|
|
||||||
get => runningStat.CurrentCount == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<string> InputPortName
|
public IEnumerable<string> InputPortName => _beginning.InputPorts.Keys;
|
||||||
{
|
|
||||||
get => _beginning.InputPorts.Keys;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<string> OutputPortName
|
public IEnumerable<string> OutputPortName => _beginning.OutputPorts.Keys;
|
||||||
{
|
|
||||||
get => _beginning.OutputPorts.Keys;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PipelineNode BeginLayer => _beginning;
|
public PipelineNode BeginLayer => _beginning;
|
||||||
|
|
||||||
public PipelineNode EndLayer => _ending;
|
public PipelineNode EndLayer => _ending;
|
||||||
|
|
||||||
public PipelineNodeOperation Operation
|
public PipelineNodeOperation Operation => (this as IConvertableToPipelineNode).NodeMain;
|
||||||
{
|
|
||||||
get => (this as IConvertableToPipelineNode).NodeMain;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
internal SemaphoreSlim RunningStat
|
internal SemaphoreSlim RunningStat => runningStat;
|
||||||
{
|
|
||||||
get => runningStat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddNode(PipelineNode node, bool isNative)
|
public void AddNode(
|
||||||
|
PipelineNode node,
|
||||||
|
bool isNative
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(node);
|
ArgumentNullException.ThrowIfNull(node);
|
||||||
node.IsNative = isNative;
|
node.IsNative = isNative;
|
||||||
@@ -161,7 +128,10 @@ namespace StgSharp.PipeLine
|
|||||||
_isAvailable = true;
|
_isAvailable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PipelineNode Create(PipelineNodeLabel label, [NotNull] IConvertableToPipelineNode body)
|
public PipelineNode Create(
|
||||||
|
PipelineNodeLabel label,
|
||||||
|
[NotNull] IConvertableToPipelineNode body
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (_allNode.TryGetValue(label, out PipelineNode? node)) {
|
if (_allNode.TryGetValue(label, out PipelineNode? node)) {
|
||||||
throw new InvalidOperationException("Label has exist in scheduler.");
|
throw new InvalidOperationException("Label has exist in scheduler.");
|
||||||
@@ -171,7 +141,9 @@ namespace StgSharp.PipeLine
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PipelineNode GetNode(PipelineNodeLabel label)
|
public PipelineNode GetNode(
|
||||||
|
PipelineNodeLabel label
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (_allNode.TryGetValue(label, out PipelineNode? node))
|
if (_allNode.TryGetValue(label, out PipelineNode? node))
|
||||||
{
|
{
|
||||||
@@ -182,14 +154,19 @@ namespace StgSharp.PipeLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LinkToInput(PipelineNodeInPort port)
|
public void LinkToInput(
|
||||||
|
PipelineNodeInPort port
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(port);
|
ArgumentNullException.ThrowIfNull(port);
|
||||||
PipelineNodeOutPort p = _beginning.DefaultOut;
|
PipelineNodeOutPort p = _beginning.DefaultOut;
|
||||||
p.Connect(port);
|
p.Connect(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LinkToInput(PipelineNodeInPort port, string inputPortName)
|
public void LinkToInput(
|
||||||
|
PipelineNodeInPort port,
|
||||||
|
string inputPortName
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(port);
|
ArgumentNullException.ThrowIfNull(port);
|
||||||
PipelineNodeOutPort p = _beginning.DefineCertainOutputPort(inputPortName);
|
PipelineNodeOutPort p = _beginning.DefineCertainOutputPort(inputPortName);
|
||||||
@@ -197,7 +174,9 @@ namespace StgSharp.PipeLine
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void SetInput(params (string label, IPipeLineConnectionPayload arg)[] parameters)
|
public void SetInput(
|
||||||
|
params (string label, IPipeLineConnectionPayload arg)[] parameters
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_beginning.SetInputData(parameters);
|
_beginning.SetInputData(parameters);
|
||||||
}
|
}
|
||||||
@@ -211,7 +190,8 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
public bool TryGetAllNode(
|
public bool TryGetAllNode(
|
||||||
out List<List<PipelineNode>> mainThreadNodes,
|
out List<List<PipelineNode>> mainThreadNodes,
|
||||||
out List<List<PipelineNode>> concurrentNodes)
|
out List<List<PipelineNode>> concurrentNodes
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (_isAvailable)
|
if (_isAvailable)
|
||||||
{
|
{
|
||||||
@@ -224,7 +204,9 @@ namespace StgSharp.PipeLine
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool RequestNexConcurrentNode(out PipelineNode node)
|
internal bool RequestNexConcurrentNode(
|
||||||
|
out PipelineNode node
|
||||||
|
)
|
||||||
{
|
{
|
||||||
int index, level;
|
int index, level;
|
||||||
if (cLevel >= _concurrentNodes.Count)
|
if (cLevel >= _concurrentNodes.Count)
|
||||||
@@ -251,7 +233,9 @@ namespace StgSharp.PipeLine
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool RequestNextMainThreadNode(out PipelineNode node)
|
internal bool RequestNextMainThreadNode(
|
||||||
|
out PipelineNode node
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (mtLevel >= _mainThreadNodes.Count)
|
if (mtLevel >= _mainThreadNodes.Count)
|
||||||
{
|
{
|
||||||
@@ -280,7 +264,8 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
void IConvertableToPipelineNode.NodeMain(
|
void IConvertableToPipelineNode.NodeMain(
|
||||||
in Dictionary<string, PipelineNodeInPort> input,
|
in Dictionary<string, PipelineNodeInPort> input,
|
||||||
in Dictionary<string, PipelineNodeOutPort> output)
|
in Dictionary<string, PipelineNodeOutPort> output
|
||||||
|
)
|
||||||
{
|
{
|
||||||
PipeLineRunner.Run(this);
|
PipeLineRunner.Run(this);
|
||||||
PipelineNodeOutPort.SkipAll(output);
|
PipelineNodeOutPort.SkipAll(output);
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="PortArgs"
|
// file="PortArgs"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -45,7 +25,10 @@ namespace StgSharp.PipeLine
|
|||||||
private protected PipelineNodeOutPort input;
|
private protected PipelineNodeOutPort input;
|
||||||
private protected SemaphoreSlim formerCompleteSemaphore;
|
private protected SemaphoreSlim formerCompleteSemaphore;
|
||||||
|
|
||||||
public PipelineConnector(PipelineNodeOutPort former, PipelineNodeInPort after)
|
public PipelineConnector(
|
||||||
|
PipelineNodeOutPort former,
|
||||||
|
PipelineNodeInPort after
|
||||||
|
)
|
||||||
{
|
{
|
||||||
this.input = former;
|
this.input = former;
|
||||||
this.output = after;
|
this.output = after;
|
||||||
@@ -62,7 +45,9 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
public PipelineNodeOutPort Input => input;
|
public PipelineNodeOutPort Input => input;
|
||||||
|
|
||||||
public static void SkipAll(Dictionary<string, PipelineConnector> ports)
|
public static void SkipAll(
|
||||||
|
Dictionary<string, PipelineConnector> ports
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (ports == null) {
|
if (ports == null) {
|
||||||
return;
|
return;
|
||||||
@@ -75,7 +60,9 @@ namespace StgSharp.PipeLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WaitAll(Dictionary<string, PipelineConnector> ports)
|
public static void WaitAll(
|
||||||
|
Dictionary<string, PipelineConnector> ports
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (ports == null) {
|
if (ports == null) {
|
||||||
return;
|
return;
|
||||||
@@ -110,7 +97,9 @@ namespace StgSharp.PipeLine
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void CompleteAndWriteData(IPipeLineConnectionPayload args)
|
public void CompleteAndWriteData(
|
||||||
|
IPipeLineConnectionPayload args
|
||||||
|
)
|
||||||
{
|
{
|
||||||
this.args = args;
|
this.args = args;
|
||||||
CompleteAndSkip();
|
CompleteAndSkip();
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="SideNode"
|
// file="SideNode"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
@@ -43,9 +23,11 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
private PipelineScheduler _bp;
|
private PipelineScheduler _bp;
|
||||||
|
|
||||||
public BeginningNode(PipelineScheduler bp)
|
public BeginningNode(
|
||||||
: base(
|
PipelineScheduler bp
|
||||||
DefaultOperation, new PipelineNodeStringLabel("BeginningNode"), true, [ "default" ],[ OutName ])
|
)
|
||||||
|
: base(DefaultOperation, new PipelineNodeStringLabel("BeginningNode"), true,
|
||||||
|
["default"], [OutName])
|
||||||
{
|
{
|
||||||
_bp = bp;
|
_bp = bp;
|
||||||
}
|
}
|
||||||
@@ -58,7 +40,9 @@ namespace StgSharp.PipeLine
|
|||||||
PipelineNodeOutPort.SkipAll(_output);
|
PipelineNodeOutPort.SkipAll(_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetInputData(IEnumerable<(string, IPipeLineConnectionPayload)> data)
|
internal void SetInputData(
|
||||||
|
IEnumerable<(string, IPipeLineConnectionPayload)> data
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (data is null) {
|
if (data is null) {
|
||||||
return;
|
return;
|
||||||
@@ -75,9 +59,11 @@ namespace StgSharp.PipeLine
|
|||||||
|
|
||||||
private PipelineScheduler _bp;
|
private PipelineScheduler _bp;
|
||||||
|
|
||||||
public EndingNode(PipelineScheduler bp)
|
public EndingNode(
|
||||||
: base(
|
PipelineScheduler bp
|
||||||
DefaultOperation, name:new PipelineNodeStringLabel("EndingNode"), true, [ "default" ],[ "default" ])
|
)
|
||||||
|
: base(DefaultOperation, name:new PipelineNodeStringLabel("EndingNode"), true,
|
||||||
|
["default"], ["default"])
|
||||||
{
|
{
|
||||||
_bp = bp;
|
_bp = bp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="ISimpleStateMachine"
|
// file="ISimpleStateMachine"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="SimpleStateMachineNode"
|
// file="SimpleStateMachineNode"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -1,33 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
// file="StateContext"
|
||||||
// file="StateContext.cs"
|
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person
|
|
||||||
// obtaining a copy of this software and associated documentation
|
|
||||||
// files (the “Software”), to deal in the Software without restriction,
|
|
||||||
// including without limitation the rights to use, copy, modify, merge,
|
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
// and to permit persons to whom the Software is furnished to do so,
|
|
||||||
// subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and
|
|
||||||
// this permission notice shall be included in all copies
|
|
||||||
// or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
|
||||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
||||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
|
||||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="AdaptiveBackoffStrategy"
|
// file="AdaptiveBackoffStrategy"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
@@ -109,14 +89,17 @@ public struct AdaptiveBackoffStrategy
|
|||||||
_currentMethod = s_globalBestMethod,
|
_currentMethod = s_globalBestMethod,
|
||||||
_consecutiveFailures = 0,
|
_consecutiveFailures = 0,
|
||||||
_localAttempts = 0,
|
_localAttempts = 0,
|
||||||
_fastRng = (uint)(Environment.TickCount64 ^ Thread.CurrentThread.ManagedThreadId * 0x9E3779B9U)
|
_fastRng =
|
||||||
|
(uint)(Environment.TickCount64 ^ Thread.CurrentThread.ManagedThreadId * 0x9E3779B9U)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets global statistics for the specified strategy (for monitoring)
|
/// Gets global statistics for the specified strategy (for monitoring)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static (long attempts, long successes, double successRate) GetGlobalStats(BackoffMethod method)
|
public static (long attempts, long successes, double successRate) GetGlobalStats(
|
||||||
|
BackoffMethod method
|
||||||
|
)
|
||||||
{
|
{
|
||||||
PerformanceStats stats = s_globalStats[(int)method];
|
PerformanceStats stats = s_globalStats[(int)method];
|
||||||
return (stats.Attempts, stats.Successes, stats.SuccessRate);
|
return (stats.Attempts, stats.Successes, stats.SuccessRate);
|
||||||
@@ -338,14 +321,12 @@ public struct AdaptiveBackoffStrategy
|
|||||||
public long LastResetTicks;
|
public long LastResetTicks;
|
||||||
public long Successes;
|
public long Successes;
|
||||||
|
|
||||||
public readonly double SuccessRate
|
public readonly double SuccessRate => Attempts == 0 ? 0.0 : (double)Successes / Attempts;
|
||||||
{
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
get => Attempts == 0 ? 0.0 : (double)Successes / Attempts;
|
|
||||||
}
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void RecordAttempt(bool success)
|
public void RecordAttempt(
|
||||||
|
bool success
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_ = Interlocked.Increment(ref Attempts);
|
_ = Interlocked.Increment(ref Attempts);
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="BufferExpansionLock"
|
// file="BufferExpansionLock"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -53,11 +33,7 @@ namespace StgSharp.Threading
|
|||||||
_copyLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
|
_copyLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsThreadReadingMetaData
|
public bool IsThreadReadingMetaData => _expansionLock.IsReadLockHeld;
|
||||||
{
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
get => _expansionLock.IsReadLockHeld;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="CancellableTask"
|
// file="CancellableTask"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -48,26 +28,19 @@ namespace StgSharp.Threading
|
|||||||
cts = new CancellationTokenSource();
|
cts = new CancellationTokenSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
private protected CancellableTask(Action<CancellationToken> action)
|
private protected CancellableTask(
|
||||||
|
Action<CancellationToken> action
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_internalTask = new Task(InternalAction);
|
_internalTask = new Task(InternalAction);
|
||||||
cts = new CancellationTokenSource();
|
cts = new CancellationTokenSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsCompleted
|
public bool IsCompleted => _internalTask.IsCompleted;
|
||||||
{
|
|
||||||
get => _internalTask.IsCompleted;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CancellationTokenSource Cts
|
public CancellationTokenSource Cts => cts;
|
||||||
{
|
|
||||||
get => cts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Id
|
public int Id => _internalTask.Id;
|
||||||
{
|
|
||||||
get => _internalTask.Id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Cancel()
|
public void Cancel()
|
||||||
{
|
{
|
||||||
@@ -91,7 +64,9 @@ namespace StgSharp.Threading
|
|||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CancellableTask Run(Action<CancellationToken> startup)
|
public static CancellableTask Run(
|
||||||
|
Action<CancellationToken> startup
|
||||||
|
)
|
||||||
{
|
{
|
||||||
CancellableTask ret = new CancellableTask
|
CancellableTask ret = new CancellableTask
|
||||||
{
|
{
|
||||||
@@ -106,7 +81,9 @@ namespace StgSharp.Threading
|
|||||||
_internalTask.Wait();
|
_internalTask.Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WaitAll(IEnumerable<CancellableTask> tasks)
|
public static void WaitAll(
|
||||||
|
IEnumerable<CancellableTask> tasks
|
||||||
|
)
|
||||||
{
|
{
|
||||||
IEnumerable<Task> convertedTasks = tasks.Select<CancellableTask, Task>(
|
IEnumerable<Task> convertedTasks = tasks.Select<CancellableTask, Task>(
|
||||||
ct => ct._internalTask);
|
ct => ct._internalTask);
|
||||||
@@ -119,7 +96,9 @@ namespace StgSharp.Threading
|
|||||||
_startup(Cts.Token);
|
_startup(Cts.Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(
|
||||||
|
bool disposing
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!disposedValue)
|
if (!disposedValue)
|
||||||
{
|
{
|
||||||
@@ -140,7 +119,9 @@ namespace StgSharp.Threading
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator Task(CancellableTask task)
|
public static implicit operator Task(
|
||||||
|
CancellableTask task
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return task._internalTask;
|
return task._internalTask;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="SingleConsumerBell"
|
// file="SingleConsumerBell"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
@@ -34,15 +14,15 @@ namespace StgSharp.Threading
|
|||||||
/// A single-consumer bell/signal primitive.
|
/// A single-consumer bell/signal primitive.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para> Producers can call <see cref="Set" /> multiple times to publish signals. The bell
|
/// <para>Producers can call <see cref="Set" /> multiple times to publish signals. The bell
|
||||||
/// keeps a pending count of not-yet-consumed signals. The consumer uses <see
|
/// keeps a pending count of not-yet-consumed signals. The consumer uses <see
|
||||||
/// cref="Wait(object, CancellationToken)" /> or <see cref="TryWait(object)" /> to consume
|
/// cref="Wait(object, CancellationToken)" /> or <see cref="TryWait(object)" /> to consume
|
||||||
/// signals.</para> <para> When a producer increments the pending count from 0 to 1, the
|
/// signals. </para> <para>When a producer increments the pending count from 0 to 1, the
|
||||||
/// internal event is set to wake the consumer. Consuming via <see cref="TryWait(object)" />
|
/// internal event is set to wake the consumer. Consuming via <see cref="TryWait(object)" />
|
||||||
/// or <see cref="Wait(object, CancellationToken)" /> clears the entire pending count
|
/// or <see cref="Wait(object, CancellationToken)" /> clears the entire pending count
|
||||||
/// (aggregate consumption). If new signals arrive while resetting, the event is set again to
|
/// (aggregate consumption). If new signals arrive while resetting, the event is set again to
|
||||||
/// avoid missed signals.</para> <para> Ownership: only the specified <c> owner </c> can call
|
/// avoid missed signals. </para> <para>Ownership: only the specified <c> owner </c> can call
|
||||||
/// the consumer APIs.</para>
|
/// the consumer APIs. </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public sealed class SingleConsumerBell : IDisposable
|
public sealed class SingleConsumerBell : IDisposable
|
||||||
{
|
{
|
||||||
@@ -65,7 +45,10 @@ namespace StgSharp.Threading
|
|||||||
/// <exception cref="ArgumentNullException">
|
/// <exception cref="ArgumentNullException">
|
||||||
/// Thrown if <paramref name="owner" /> is null.
|
/// Thrown if <paramref name="owner" /> is null.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public SingleConsumerBell(object owner, int spinCount = 100)
|
public SingleConsumerBell(
|
||||||
|
object owner,
|
||||||
|
int spinCount = 100
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_owner = owner ?? throw new ArgumentNullException(nameof(owner));
|
_owner = owner ?? throw new ArgumentNullException(nameof(owner));
|
||||||
_evt = new ManualResetEventSlim(false, spinCount);
|
_evt = new ManualResetEventSlim(false, spinCount);
|
||||||
@@ -113,13 +96,15 @@ namespace StgSharp.Threading
|
|||||||
/// The consumer object; must be the same reference provided at construction.
|
/// The consumer object; must be the same reference provided at construction.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// <c> true </c> if a signal was available (pending or event set); otherwise <c> false
|
/// <c> true </c> if a signal was available (pending or event set); otherwise
|
||||||
/// </c>.
|
/// <c>false</c>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="InvalidOperationException">
|
/// <exception cref="InvalidOperationException">
|
||||||
/// Thrown if <paramref name="consumer" /> is not the owner.
|
/// Thrown if <paramref name="consumer" /> is not the owner.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public bool TryWait(object consumer)
|
public bool TryWait(
|
||||||
|
object consumer
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!ReferenceEquals(_owner, consumer)) {
|
if (!ReferenceEquals(_owner, consumer)) {
|
||||||
throw new InvalidOperationException("This bell is owned by another consumer.");
|
throw new InvalidOperationException("This bell is owned by another consumer.");
|
||||||
@@ -153,7 +138,10 @@ namespace StgSharp.Threading
|
|||||||
/// <exception cref="InvalidOperationException">
|
/// <exception cref="InvalidOperationException">
|
||||||
/// Thrown if <paramref name="consumer" /> is not the owner.
|
/// Thrown if <paramref name="consumer" /> is not the owner.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public void Wait(object consumer, CancellationToken cancellationToken = default)
|
public void Wait(
|
||||||
|
object consumer,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!ReferenceEquals(_owner, consumer)) {
|
if (!ReferenceEquals(_owner, consumer)) {
|
||||||
throw new InvalidOperationException("This bell is owned by another consumer.");
|
throw new InvalidOperationException("This bell is owned by another consumer.");
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="ThreadHelper"
|
// file="ThreadHelper"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.HighPerformance.ProcessorAbstraction;
|
using StgSharp.HighPerformance.ProcessorAbstraction;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="VariableCapacitySemaphore"
|
// file="VariableCapacitySemaphore"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="StgSharpTime"
|
// file="StgSharpTime"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Collections;
|
using StgSharp.Collections;
|
||||||
using StgSharp.Timing;
|
using StgSharp.Timing;
|
||||||
using System;
|
using System;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="TimeSequence"
|
// file="TimeSequence"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Timing;
|
using StgSharp.Timing;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="TimeSourceProvider"
|
// file="TimeSourceProvider"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp;
|
using StgSharp;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@@ -40,7 +20,9 @@ namespace StgSharp.Timing
|
|||||||
|
|
||||||
protected object SubscribeLock { get; } = new();
|
protected object SubscribeLock { get; } = new();
|
||||||
|
|
||||||
public void AddSubscriber(TimeSpanProvider subscriber)
|
public void AddSubscriber(
|
||||||
|
TimeSpanProvider subscriber
|
||||||
|
)
|
||||||
{
|
{
|
||||||
lock (SubscribeLock) {
|
lock (SubscribeLock) {
|
||||||
AddSubscriberUnsynced(subscriber);
|
AddSubscriberUnsynced(subscriber);
|
||||||
@@ -49,7 +31,9 @@ namespace StgSharp.Timing
|
|||||||
|
|
||||||
public abstract long GetCurrentTimeSpanTick();
|
public abstract long GetCurrentTimeSpanTick();
|
||||||
|
|
||||||
public void RemoveSubscriber(TimeSpanProvider subscriber)
|
public void RemoveSubscriber(
|
||||||
|
TimeSpanProvider subscriber
|
||||||
|
)
|
||||||
{
|
{
|
||||||
lock (SubscribeLock) {
|
lock (SubscribeLock) {
|
||||||
RemoveSubscriberUnsynced(subscriber);
|
RemoveSubscriberUnsynced(subscriber);
|
||||||
@@ -60,9 +44,13 @@ namespace StgSharp.Timing
|
|||||||
|
|
||||||
public abstract void StopProvidingTime();
|
public abstract void StopProvidingTime();
|
||||||
|
|
||||||
protected abstract void AddSubscriberUnsynced(TimeSpanProvider subscriber);
|
protected abstract void AddSubscriberUnsynced(
|
||||||
|
TimeSpanProvider subscriber
|
||||||
|
);
|
||||||
|
|
||||||
protected abstract void RemoveSubscriberUnsynced(TimeSpanProvider subscriber);
|
protected abstract void RemoveSubscriberUnsynced(
|
||||||
|
TimeSpanProvider subscriber
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="TimeSpanProvider.Awaiting"
|
// file="TimeSpanProvider.Awaiting"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.HighPerformance.Memory;
|
using StgSharp.HighPerformance.Memory;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@@ -77,11 +57,7 @@ namespace StgSharp.Timing
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public long PendingSpanCount => Volatile.Read(ref _pendingSpans);
|
public long PendingSpanCount => Volatile.Read(ref _pendingSpans);
|
||||||
|
|
||||||
internal ManualResetEventSlim AwaitingEvent
|
internal ManualResetEventSlim AwaitingEvent => _event;
|
||||||
{
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
get => _event;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
@@ -92,7 +68,10 @@ namespace StgSharp.Timing
|
|||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode() => _id;
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
|
|
||||||
public void Participant()
|
public void Participant()
|
||||||
{
|
{
|
||||||
@@ -154,7 +133,9 @@ namespace StgSharp.Timing
|
|||||||
/// OperationCanceledException when token is cancelled. If the provider is disposed during
|
/// OperationCanceledException when token is cancelled. If the provider is disposed during
|
||||||
/// wait an OperationCanceledException is thrown to indicate end.
|
/// wait an OperationCanceledException is thrown to indicate end.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Task WaitNextSpanAsync(CancellationToken ct)
|
public Task WaitNextSpanAsync(
|
||||||
|
CancellationToken ct
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Block the current thread until the event is signaled or cancellation requested.
|
// Block the current thread until the event is signaled or cancellation requested.
|
||||||
_event.Wait(ct);
|
_event.Wait(ct);
|
||||||
@@ -181,7 +162,10 @@ namespace StgSharp.Timing
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void MissRefresh() => _missHandler?.Invoke(this, EventArgs.Empty); // Legacy compatibility.
|
internal void MissRefresh()
|
||||||
|
{
|
||||||
|
_missHandler?.Invoke(this, EventArgs.Empty);
|
||||||
|
} // Legacy compatibility.
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -193,7 +177,9 @@ namespace StgSharp.Timing
|
|||||||
/// True if the span provider is working. False if time is over (the sequence ended).
|
/// True if the span provider is working. False if time is over (the sequence ended).
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal bool OnSpanTick(long currentTick)
|
internal bool OnSpanTick(
|
||||||
|
long currentTick
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (_sequence.EndsAt(currentTick))
|
if (_sequence.EndsAt(currentTick))
|
||||||
{
|
{
|
||||||
@@ -228,7 +214,10 @@ namespace StgSharp.Timing
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
~TimeSpanProvider() => Dispose();
|
~TimeSpanProvider()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="TimeSpanProvider"
|
// file="TimeSpanProvider"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Timing;
|
using StgSharp.Timing;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="IImageProvider"
|
// file="IImageProvider"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="ImageHelper"
|
// file="ImageHelper"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@@ -35,7 +15,12 @@ namespace StgSharp.Graphics
|
|||||||
public static class ImageHelper
|
public static class ImageHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
public static void Resize(Image i, int width, int height, ImageMovement move)
|
public static void Resize(
|
||||||
|
Image i,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
ImageMovement move
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (i == null) {
|
if (i == null) {
|
||||||
throw new ArgumentNullException(nameof(i));
|
throw new ArgumentNullException(nameof(i));
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="Camera"
|
// file="Camera"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Graphics.OpenGL;
|
using StgSharp.Graphics.OpenGL;
|
||||||
using StgSharp.Graphics.ShaderEdit;
|
using StgSharp.Graphics.ShaderEdit;
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="BufferObjectBase"
|
// file="BufferObjectBase"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Graphics;
|
using StgSharp.Graphics;
|
||||||
using StgSharp.Graphics.OpenGL;
|
using StgSharp.Graphics.OpenGL;
|
||||||
using System;
|
using System;
|
||||||
@@ -53,7 +33,9 @@ namespace StgSharp.Graphics
|
|||||||
/// <returns>
|
/// <returns>
|
||||||
///
|
///
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public GlHandle this[int index] => _bufferHandle[index];
|
public GlHandle this[
|
||||||
|
int index
|
||||||
|
] => _bufferHandle[index];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bind a BufferHandle instance to OpenGL
|
/// Bind a BufferHandle instance to OpenGL
|
||||||
@@ -61,7 +43,9 @@ namespace StgSharp.Graphics
|
|||||||
/// <param _label="index">
|
/// <param _label="index">
|
||||||
/// Index of handle of the object in this instance to be bind
|
/// Index of handle of the object in this instance to be bind
|
||||||
/// </param>
|
/// </param>
|
||||||
public abstract void Bind(int index);
|
public abstract void Bind(
|
||||||
|
int index
|
||||||
|
);
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
@@ -75,7 +59,9 @@ namespace StgSharp.Graphics
|
|||||||
return $"This is a {GetType().FullName}, containing {_bufferHandle.Length} buffer handles: {_bufferHandle.ToString()}.";
|
return $"This is a {GetType().FullName}, containing {_bufferHandle.Length} buffer handles: {_bufferHandle.ToString()}.";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void Dispose(bool disposing);
|
protected abstract void Dispose(
|
||||||
|
bool disposing
|
||||||
|
);
|
||||||
|
|
||||||
~BufferObjectBase()
|
~BufferObjectBase()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="Monitor"
|
// file="Monitor"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="FrameworkConstant"
|
// file="FrameworkConstant"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -1,29 +1,9 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="Global"
|
// file="Global"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
global using StgSharp.Internal;
|
global using StgSharp.Internal;
|
||||||
global using System;
|
global using System;
|
||||||
@@ -1,30 +1,9 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="GraphicInitializer"
|
// file="GraphicInitializer"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
|
|
||||||
using StgSharp;
|
using StgSharp;
|
||||||
using System;
|
using System;
|
||||||
@@ -41,7 +20,9 @@ namespace StgSharp.Graphics
|
|||||||
|
|
||||||
public string ModuleName => "Graphics";
|
public string ModuleName => "Graphics";
|
||||||
|
|
||||||
public void InitializeModule(IModuleInitializeProfile profile)
|
public void InitializeModule(
|
||||||
|
IModuleInitializeProfile profile
|
||||||
|
)
|
||||||
{
|
{
|
||||||
GraphicFramework.LoadGlfw();
|
GraphicFramework.LoadGlfw();
|
||||||
if (GraphicFramework.glfwInit() == 0) {
|
if (GraphicFramework.glfwInit() == 0) {
|
||||||
|
|||||||
+29
-40
@@ -1,33 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
// file="Image"
|
||||||
// file="Image.cs"
|
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person
|
|
||||||
// obtaining a copy of this software and associated documentation
|
|
||||||
// files (the “Software”), to deal in the Software without restriction,
|
|
||||||
// including without limitation the rights to use, copy, modify, merge,
|
|
||||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
// and to permit persons to whom the Software is furnished to do so,
|
|
||||||
// subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and
|
|
||||||
// this permission notice shall be included in all copies
|
|
||||||
// or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
|
||||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
||||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
|
||||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Graphics.OpenGL;
|
using StgSharp.Graphics.OpenGL;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@@ -47,7 +24,9 @@ namespace StgSharp.Graphics
|
|||||||
_rawInfo = new ImageInfo();
|
_rawInfo = new ImageInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Image(ImageInfo information)
|
internal Image(
|
||||||
|
ImageInfo information
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_rawInfo = information;
|
_rawInfo = information;
|
||||||
_data = [];
|
_data = [];
|
||||||
@@ -55,11 +34,7 @@ namespace StgSharp.Graphics
|
|||||||
// int length = _rawInfo.width * _rawInfo.height * _rawInfo.channel;
|
// int length = _rawInfo.width * _rawInfo.height * _rawInfo.channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public (int width, int height) Size
|
public (int width, int height) Size => (_rawInfo.Width, _rawInfo.Height);
|
||||||
{
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
get => (_rawInfo.Width, _rawInfo.Height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] PixelBuffer
|
public byte[] PixelBuffer
|
||||||
{
|
{
|
||||||
@@ -109,9 +84,14 @@ namespace StgSharp.Graphics
|
|||||||
|
|
||||||
internal ref byte[] Data => ref _data;
|
internal ref byte[] Data => ref _data;
|
||||||
|
|
||||||
public void FromBytes(byte[] stream) { }
|
public void FromBytes(
|
||||||
|
byte[] stream
|
||||||
|
) { }
|
||||||
|
|
||||||
public static unsafe Image FromFile(string route, ImageLoader loader)
|
public static unsafe Image FromFile(
|
||||||
|
string route,
|
||||||
|
ImageLoader loader
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Image ret = new Image();
|
Image ret = new Image();
|
||||||
fixed (ImageInfo* iptr = &ret._rawInfo) {
|
fixed (ImageInfo* iptr = &ret._rawInfo) {
|
||||||
@@ -120,7 +100,11 @@ namespace StgSharp.Graphics
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Image FromMemory((int width, int height) size, ImageChannel channel, byte[] stream)
|
public static Image FromMemory(
|
||||||
|
(int width, int height) size,
|
||||||
|
ImageChannel channel,
|
||||||
|
byte[] stream
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ImageInfo _info = new ImageInfo
|
ImageInfo _info = new ImageInfo
|
||||||
{
|
{
|
||||||
@@ -139,7 +123,8 @@ namespace StgSharp.Graphics
|
|||||||
(int width, int height) size,
|
(int width, int height) size,
|
||||||
ImageChannel channel,
|
ImageChannel channel,
|
||||||
PixelChannelLayout layout,
|
PixelChannelLayout layout,
|
||||||
byte[] stream)
|
byte[] stream
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ImageInfo _info = new ImageInfo
|
ImageInfo _info = new ImageInfo
|
||||||
{
|
{
|
||||||
@@ -173,7 +158,11 @@ namespace StgSharp.Graphics
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Image FromMemory(ImageInfo info, byte[] data, int operationCount)
|
internal static Image FromMemory(
|
||||||
|
ImageInfo info,
|
||||||
|
byte[] data,
|
||||||
|
int operationCount
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return new Image
|
return new Image
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="ImageInfo"
|
// file="ImageInfo"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Graphics.OpenGL;
|
using StgSharp.Graphics.OpenGL;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -40,7 +20,8 @@ namespace StgSharp.Graphics
|
|||||||
ref int width,
|
ref int width,
|
||||||
ref int height,
|
ref int height,
|
||||||
ref int definedChannel,
|
ref int definedChannel,
|
||||||
int desiredChannel);
|
int desiredChannel
|
||||||
|
);
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
internal struct ImageInfo
|
internal struct ImageInfo
|
||||||
@@ -55,13 +36,10 @@ namespace StgSharp.Graphics
|
|||||||
public ImageChannel Channel
|
public ImageChannel Channel
|
||||||
{
|
{
|
||||||
get => channel;
|
get => channel;
|
||||||
set { channel = value; }
|
set => channel = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ChannelCount
|
public int ChannelCount => GetChannelCount(channel);
|
||||||
{
|
|
||||||
get => GetChannelCount(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Height
|
public int Height
|
||||||
{
|
{
|
||||||
@@ -69,11 +47,8 @@ namespace StgSharp.Graphics
|
|||||||
set => height = value;
|
set => height = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int StreamSize
|
public int StreamSize => width * height * GetPixelSize(
|
||||||
{
|
|
||||||
get => width * height * GetPixelSize(
|
|
||||||
pixelLayout, channel);
|
pixelLayout, channel);
|
||||||
}
|
|
||||||
|
|
||||||
public int Width
|
public int Width
|
||||||
{
|
{
|
||||||
@@ -101,7 +76,9 @@ namespace StgSharp.Graphics
|
|||||||
return $"{channel}\t{width}\t{height}\t{(ulong)StreamPtr}";
|
return $"{channel}\t{width}\t{height}\t{(ulong)StreamPtr}";
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static int GetChannelCount(ImageChannel channel)
|
internal static int GetChannelCount(
|
||||||
|
ImageChannel channel
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return channel switch
|
return channel switch
|
||||||
{
|
{
|
||||||
@@ -114,7 +91,10 @@ namespace StgSharp.Graphics
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static int GetPixelSize(PixelChannelLayout layout, ImageChannel channel)
|
internal static int GetPixelSize(
|
||||||
|
PixelChannelLayout layout,
|
||||||
|
ImageChannel channel
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return layout switch
|
return layout switch
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="AutoTexture"
|
// file="AutoTexture"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Collections;
|
using StgSharp.Collections;
|
||||||
using StgSharp.Graphics;
|
using StgSharp.Graphics;
|
||||||
using System;
|
using System;
|
||||||
@@ -40,9 +20,9 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A collection of a sets of OpenGL textures. The collection can automatically select one of
|
/// A collection of a sets of OpenGL textures. The collection can automatically select one of
|
||||||
/// the texture with minimum costs to upgrade pixels to BufferHandle. Usually <see
|
/// the texture with minimum costs to upgrade pixels to BufferHandle. Usually <see ///
|
||||||
/// cref="AutoTextureGL" /> is used for <see cref="IImageProvider" /> loading, but not for
|
/// cref="AutoTextureGL" /> is used for <see cref="IImageProvider" /> loading, but not for
|
||||||
/// target of <see cref="OpenGLFunction.FrameBufferTexture2d(FrameBufferTarget, uint,
|
/// target of <see cref="OpenGLFunction.FrameBufferTexture2d(FrameBufferTarget, uint, ///
|
||||||
/// Texture2DTarget, GlHandle, int)" />.
|
/// Texture2DTarget, GlHandle, int)" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class AutoTextureGL
|
public sealed class AutoTextureGL
|
||||||
@@ -60,7 +40,9 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
|
|
||||||
private TextureProperty _textureProperty;
|
private TextureProperty _textureProperty;
|
||||||
|
|
||||||
private AutoTextureGL(TextureGL texture)
|
private AutoTextureGL(
|
||||||
|
TextureGL texture
|
||||||
|
)
|
||||||
{
|
{
|
||||||
texturePackage = texture;
|
texturePackage = texture;
|
||||||
_size = texture.Count;
|
_size = texture.Count;
|
||||||
@@ -70,7 +52,10 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
propertyCache = new TextureProperty[_size];
|
propertyCache = new TextureProperty[_size];
|
||||||
}
|
}
|
||||||
|
|
||||||
public AutoTextureGL(int textureObjectSize, [NotNull]glRender binding)
|
public AutoTextureGL(
|
||||||
|
int textureObjectSize,
|
||||||
|
[NotNull]glRender binding
|
||||||
|
)
|
||||||
{
|
{
|
||||||
this._size = textureObjectSize;
|
this._size = textureObjectSize;
|
||||||
imageIndexMap = new BidirectionalDictionary<Image, int>();
|
imageIndexMap = new BidirectionalDictionary<Image, int>();
|
||||||
@@ -86,20 +71,22 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
set => _textureProperty = value;
|
set => _textureProperty = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OpenGLFunction GL
|
private OpenGLFunction GL => texturePackage.GL;
|
||||||
{
|
|
||||||
get => texturePackage.GL;
|
|
||||||
}
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void SelectTextureAndBind(Image i)
|
public void SelectTextureAndBind(
|
||||||
|
Image i
|
||||||
|
)
|
||||||
{
|
{
|
||||||
TextureProperty property = _textureProperty;
|
TextureProperty property = _textureProperty;
|
||||||
|
|
||||||
SelectTextureAndBind(i, property);
|
SelectTextureAndBind(i, property);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectTextureAndBind([NotNull]Image i, TextureProperty property)
|
public void SelectTextureAndBind(
|
||||||
|
[NotNull]Image i,
|
||||||
|
TextureProperty property
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// usable texture with image match
|
// usable texture with image match
|
||||||
if (imageIndexMap.TryGetValue(i, out int index))
|
if (imageIndexMap.TryGetValue(i, out int index))
|
||||||
@@ -148,7 +135,9 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AutoTextureGL ToAuto([NotNull]TextureGL texture)
|
public static AutoTextureGL ToAuto(
|
||||||
|
[NotNull]TextureGL texture
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (texture.IndexOfCurrentTexture != -1) {
|
if (texture.IndexOfCurrentTexture != -1) {
|
||||||
throw new InvalidOperationException("Texture to be converted has been editted.");
|
throw new InvalidOperationException("Texture to be converted has been editted.");
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="EBO"
|
// file="EBO"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Graphics;
|
using StgSharp.Graphics;
|
||||||
using StgSharp.Graphics.OpenGL;
|
using StgSharp.Graphics.OpenGL;
|
||||||
|
|
||||||
@@ -40,37 +20,52 @@ using System.Text;
|
|||||||
namespace StgSharp.Graphics.OpenGL
|
namespace StgSharp.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A collection of handle to Element BufferHandle Object in OpenglFunc. Each <see
|
/// A collection of handle to Element BufferHandle Object in OpenglFunc. Each <see ///
|
||||||
/// langword="uint" /> value indexed from instance of this class this is the only handle to
|
/// langword="uint" /> value indexed from instance of this class this is the only handle to
|
||||||
/// one Element BufferHandle Object.
|
/// one Element BufferHandle Object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed unsafe class ElementBuffer : GlBufferObjectBase
|
public sealed unsafe class ElementBuffer : GlBufferObjectBase
|
||||||
{
|
{
|
||||||
|
|
||||||
internal ElementBuffer(int n, glRender binding)
|
internal ElementBuffer(
|
||||||
|
int n,
|
||||||
|
glRender binding
|
||||||
|
)
|
||||||
: base(binding)
|
: base(binding)
|
||||||
{
|
{
|
||||||
_bufferHandle = GL.GenBuffers(n);
|
_bufferHandle = GL.GenBuffers(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed override void Bind(int index)
|
public sealed override void Bind(
|
||||||
|
int index
|
||||||
|
)
|
||||||
{
|
{
|
||||||
GL.BindBuffer(BufferType.ElementArrayBuffer, _bufferHandle[index]);
|
GL.BindBuffer(BufferType.ElementArrayBuffer, _bufferHandle[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetValue<T>(int index, T[] bufferArray, BufferUsage usage) where T: unmanaged, INumber<T>
|
public void SetValue<T>(
|
||||||
|
int index,
|
||||||
|
T[] bufferArray,
|
||||||
|
BufferUsage usage
|
||||||
|
) where T : unmanaged, INumber<T>
|
||||||
{
|
{
|
||||||
GL.BindBuffer(BufferType.ElementArrayBuffer, _bufferHandle[index]);
|
GL.BindBuffer(BufferType.ElementArrayBuffer, _bufferHandle[index]);
|
||||||
GL.SetBufferData<T>(BufferType.ElementArrayBuffer, bufferArray, usage);
|
GL.SetBufferData<T>(BufferType.ElementArrayBuffer, bufferArray, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetValue<T>(int index, ReadOnlySpan<T> bufferSpan, BufferUsage usage) where T: unmanaged, INumber<T>
|
public void SetValue<T>(
|
||||||
|
int index,
|
||||||
|
ReadOnlySpan<T> bufferSpan,
|
||||||
|
BufferUsage usage
|
||||||
|
) where T : unmanaged, INumber<T>
|
||||||
{
|
{
|
||||||
GL.BindBuffer(BufferType.ElementArrayBuffer, _bufferHandle[index]);
|
GL.BindBuffer(BufferType.ElementArrayBuffer, _bufferHandle[index]);
|
||||||
GL.SetBufferData<T>(BufferType.ElementArrayBuffer, bufferSpan, usage);
|
GL.SetBufferData<T>(BufferType.ElementArrayBuffer, bufferSpan, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected sealed override void Dispose(bool disposing)
|
protected sealed override void Dispose(
|
||||||
|
bool disposing
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
GL.DeleteBuffers(_bufferHandle);
|
GL.DeleteBuffers(_bufferHandle);
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="FBO"
|
// file="FBO"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Graphics;
|
using StgSharp.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="GLBufferObjectBase"
|
// file="GLBufferObjectBase"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Graphics.OpenGL;
|
using StgSharp.Graphics.OpenGL;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@@ -38,7 +18,9 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
|
|
||||||
private readonly glRender _contextBinding;
|
private readonly glRender _contextBinding;
|
||||||
|
|
||||||
protected GlBufferObjectBase(glRender contextBinding)
|
protected GlBufferObjectBase(
|
||||||
|
glRender contextBinding
|
||||||
|
)
|
||||||
{
|
{
|
||||||
binding = contextBinding;
|
binding = contextBinding;
|
||||||
_contextBinding = contextBinding;
|
_contextBinding = contextBinding;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="RBO"
|
// file="RBO"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Graphics;
|
using StgSharp.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -36,25 +16,35 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
public sealed class RenderBuffer : GlBufferObjectBase
|
public sealed class RenderBuffer : GlBufferObjectBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public RenderBuffer(int count, glRender binding)
|
public RenderBuffer(
|
||||||
|
int count,
|
||||||
|
glRender binding
|
||||||
|
)
|
||||||
: base(binding)
|
: base(binding)
|
||||||
{
|
{
|
||||||
_bufferHandle = GL.GenRenderBuffer(count);
|
_bufferHandle = GL.GenRenderBuffer(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Bind(int index)
|
public override void Bind(
|
||||||
|
int index
|
||||||
|
)
|
||||||
{
|
{
|
||||||
GL.BindRenderBuffer(this[index]);
|
GL.BindRenderBuffer(this[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Store(RenderBufferInternalFormat format, (int width, int height) size)
|
public void Store(
|
||||||
|
RenderBufferInternalFormat format,
|
||||||
|
(int width, int height) size
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if ((size.width > binding.Width) || (size.height > binding.Height)) {
|
if ((size.width > binding.Width) || (size.height > binding.Height)) {
|
||||||
World.LogWarning("FrameBuffer is larger than current canvas binding");
|
World.LogWarning("FrameBuffer is larger than current canvas binding");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(
|
||||||
|
bool disposing
|
||||||
|
)
|
||||||
{
|
{
|
||||||
foreach (GlHandle item in _bufferHandle)
|
foreach (GlHandle item in _bufferHandle)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="TextureGL"
|
// file="TextureGL"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Graphics;
|
using StgSharp.Graphics;
|
||||||
using StgSharp.HighPerformance.ProcessorAbstraction;
|
using StgSharp.HighPerformance.ProcessorAbstraction;
|
||||||
using StgSharp.Mathematics;
|
using StgSharp.Mathematics;
|
||||||
@@ -45,38 +25,41 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
private OpenGLFunction _gl;
|
private OpenGLFunction _gl;
|
||||||
internal GlHandle[] _textureHandle;
|
internal GlHandle[] _textureHandle;
|
||||||
|
|
||||||
internal TextureGL(int count, glRender binding)
|
internal TextureGL(
|
||||||
|
int count,
|
||||||
|
glRender binding
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// sourceList = new Image[count];
|
// sourceList = new Image[count];
|
||||||
this._gl = binding.GL;
|
this._gl = binding.GL;
|
||||||
_textureHandle = _gl.GenTextures(count);
|
_textureHandle = _gl.GenTextures(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlHandle this[int index]
|
public GlHandle this[
|
||||||
|
int index
|
||||||
|
]
|
||||||
{
|
{
|
||||||
get => _textureHandle[index];
|
get => _textureHandle[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Count
|
public int Count => _textureHandle.Length;
|
||||||
{
|
|
||||||
get => _textureHandle.Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
// internal Image[] sourceList;
|
// internal Image[] sourceList;
|
||||||
|
|
||||||
public int IndexOfCurrentTexture
|
public int IndexOfCurrentTexture => currentEditingTextureIndex;
|
||||||
{
|
|
||||||
get => currentEditingTextureIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal OpenGLFunction GL => _gl;
|
internal OpenGLFunction GL => _gl;
|
||||||
|
|
||||||
public void ActivateAs(TextureUnit unit)
|
public void ActivateAs(
|
||||||
|
TextureUnit unit
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_gl.ActiveTextureUnit((uint)unit);
|
_gl.ActiveTextureUnit((uint)unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Bind2D(int index)
|
public void Bind2D(
|
||||||
|
int index
|
||||||
|
)
|
||||||
{
|
{
|
||||||
currentEditingTextureIndex = index;
|
currentEditingTextureIndex = index;
|
||||||
_gl.BindTexture(glConst.TEXTURE_2D, _textureHandle[index]);
|
_gl.BindTexture(glConst.TEXTURE_2D, _textureHandle[index]);
|
||||||
@@ -91,18 +74,25 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
/// <param _label="i">
|
/// <param _label="i">
|
||||||
///
|
///
|
||||||
/// </param>
|
/// </param>
|
||||||
public unsafe void LoadTexture(int index, Image i)
|
public unsafe void LoadTexture(
|
||||||
|
int index,
|
||||||
|
Image i
|
||||||
|
)
|
||||||
{
|
{
|
||||||
byte[] handle = i.PixelBuffer;
|
byte[] handle = i.PixelBuffer;
|
||||||
_gl.TextureImage2d(Texture2DTarget.Texture2D, 0, i.Channel, i.Width, i.Height, i.Channel, i.PixelLayout,
|
_gl.TextureImage2d(Texture2DTarget.Texture2D, 0, i.Channel, i.Width, i.Height,
|
||||||
pixels:handle);
|
i.Channel, i.PixelLayout, pixels:handle);
|
||||||
_gl.GenerateMipmap(Texture2DTarget.Texture2D);
|
_gl.GenerateMipmap(Texture2DTarget.Texture2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region texture setting
|
#region texture setting
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Set2dFilterProperty(int index, TextureFilter onMinify, TextureFilter onMagnify)
|
public void Set2dFilterProperty(
|
||||||
|
int index,
|
||||||
|
TextureFilter onMinify,
|
||||||
|
TextureFilter onMagnify
|
||||||
|
)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (index != currentEditingTextureIndex)
|
if (index != currentEditingTextureIndex)
|
||||||
@@ -117,7 +107,11 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Set2dWrapProperty(int index, TextureWrap onHorizontial, TextureWrap onVertical)
|
public void Set2dWrapProperty(
|
||||||
|
int index,
|
||||||
|
TextureWrap onHorizontial,
|
||||||
|
TextureWrap onVertical
|
||||||
|
)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (index != currentEditingTextureIndex)
|
if (index != currentEditingTextureIndex)
|
||||||
@@ -132,7 +126,10 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Set2dProperty(int index, TextureProperty property)
|
public void Set2dProperty(
|
||||||
|
int index,
|
||||||
|
TextureProperty property
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Set2dFilterProperty(index, property.FilterOnMinify, property.FilterOnMagnify);
|
Set2dFilterProperty(index, property.FilterOnMinify, property.FilterOnMagnify);
|
||||||
Set2dWrapProperty(index, property.WrapOnHorizontial, property.WrapOnVertical);
|
Set2dWrapProperty(index, property.WrapOnHorizontial, property.WrapOnVertical);
|
||||||
@@ -156,7 +153,8 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
TextureFilter onMagnify,
|
TextureFilter onMagnify,
|
||||||
TextureFilter onMinify,
|
TextureFilter onMinify,
|
||||||
TextureWrap onHorizontal,
|
TextureWrap onHorizontal,
|
||||||
TextureWrap onVertical)
|
TextureWrap onVertical
|
||||||
|
)
|
||||||
{
|
{
|
||||||
FilterOnMagnify = onMagnify;
|
FilterOnMagnify = onMagnify;
|
||||||
FilterOnMinify = onMinify;
|
FilterOnMinify = onMinify;
|
||||||
@@ -188,14 +186,17 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
set => vert = value;
|
set => vert = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals([NotNullWhen(true)] object obj)
|
public override bool Equals(
|
||||||
|
[NotNullWhen(true)] object obj
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return base.Equals(obj);
|
return base.Equals(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return HashCode.Combine(FilterOnMagnify, FilterOnMagnify, WrapOnHorizontial, WrapOnVertical);
|
return HashCode.Combine(FilterOnMagnify, FilterOnMagnify, WrapOnHorizontial,
|
||||||
|
WrapOnVertical);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
@@ -203,12 +204,18 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
return $"FilterOnMagnify:{FilterOnMagnify}, " + $"FilterOnMagnify:{FilterOnMagnify}, " + $"WrapOnHorizontial:{WrapOnHorizontial}, " + $"WrapOnVertical:{WrapOnVertical}";
|
return $"FilterOnMagnify:{FilterOnMagnify}, " + $"FilterOnMagnify:{FilterOnMagnify}, " + $"WrapOnHorizontial:{WrapOnHorizontial}, " + $"WrapOnVertical:{WrapOnVertical}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator !=(TextureProperty left, TextureProperty right)
|
public static bool operator !=(
|
||||||
|
TextureProperty left,
|
||||||
|
TextureProperty right
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return left.mask != right.mask;
|
return left.mask != right.mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator ==(TextureProperty left, TextureProperty right)
|
public static bool operator ==(
|
||||||
|
TextureProperty left,
|
||||||
|
TextureProperty right
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return left.mask == right.mask;
|
return left.mask == right.mask;
|
||||||
}
|
}
|
||||||
@@ -217,10 +224,12 @@ namespace StgSharp.Graphics.OpenGL
|
|||||||
(
|
(
|
||||||
TextureFilter onMagnify, TextureFilter onMinify,
|
TextureFilter onMagnify, TextureFilter onMinify,
|
||||||
TextureWrap onHorizontial, TextureWrap onVertical
|
TextureWrap onHorizontial, TextureWrap onVertical
|
||||||
) propertyValueTuple)
|
) propertyValueTuple
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return new TextureProperty(propertyValueTuple.onMagnify, propertyValueTuple.onMinify,
|
return new TextureProperty(propertyValueTuple.onMagnify, propertyValueTuple.onMinify,
|
||||||
propertyValueTuple.onHorizontial, propertyValueTuple.onVertical);
|
propertyValueTuple.onHorizontial,
|
||||||
|
propertyValueTuple.onVertical);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="VAO"
|
// file="VAO"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Graphics;
|
using StgSharp.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="VBO"
|
// file="VBO"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Graphics;
|
using StgSharp.Graphics;
|
||||||
using StgSharp.Mathematics;
|
using StgSharp.Mathematics;
|
||||||
using StgSharp.Mathematics.Numeric;
|
using StgSharp.Mathematics.Numeric;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="IglConvertable"
|
// file="IglConvertable"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Graphics.OpenGL;
|
using StgSharp.Graphics.OpenGL;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@@ -46,7 +26,10 @@ namespace StgSharp.Graphics.ShaderEdit
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void GainAllUniforms(ShaderProgram source, params string[] uniformName);
|
public void GainAllUniforms(
|
||||||
|
ShaderProgram source,
|
||||||
|
params string[] uniformName
|
||||||
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="Shader"
|
// file="Shader"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp;
|
using StgSharp;
|
||||||
using StgSharp.Graphics;
|
using StgSharp.Graphics;
|
||||||
using StgSharp.Internal;
|
using StgSharp.Internal;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
//-----------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// file="Uniform"
|
// file="Uniform"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload
|
// Copyright (c) Nitload.
|
||||||
// Copyright (c) Nitload. All rights reserved.
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
// -----------------------------------------------------------------------------
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
using StgSharp.Graphics;
|
using StgSharp.Graphics;
|
||||||
using StgSharp.Mathematics.Graphics;
|
using StgSharp.Mathematics.Graphics;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user