add a scanner, but this seems to be a wrong solution. Change open-source head
This commit is contained in:
@@ -1,30 +1,10 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="PipelineScheduler"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -61,43 +41,30 @@ namespace StgSharp.PipeLine
|
||||
}
|
||||
/**/
|
||||
|
||||
public PipelineNode this[PipelineNodeLabel label]
|
||||
{
|
||||
get { return _allNode[label]; }
|
||||
}
|
||||
public PipelineNode this[
|
||||
PipelineNodeLabel label
|
||||
] => _allNode[label];
|
||||
|
||||
public bool IsRunning
|
||||
{
|
||||
get => runningStat.CurrentCount == 0;
|
||||
}
|
||||
public bool IsRunning => runningStat.CurrentCount == 0;
|
||||
|
||||
public IEnumerable<string> InputPortName
|
||||
{
|
||||
get => _beginning.InputPorts.Keys;
|
||||
}
|
||||
public IEnumerable<string> InputPortName => _beginning.InputPorts.Keys;
|
||||
|
||||
public IEnumerable<string> OutputPortName
|
||||
{
|
||||
get => _beginning.OutputPorts.Keys;
|
||||
}
|
||||
public IEnumerable<string> OutputPortName => _beginning.OutputPorts.Keys;
|
||||
|
||||
public PipelineNode BeginLayer => _beginning;
|
||||
|
||||
public PipelineNode EndLayer => _ending;
|
||||
|
||||
public PipelineNodeOperation Operation
|
||||
{
|
||||
get => (this as IConvertableToPipelineNode).NodeMain;
|
||||
}
|
||||
public PipelineNodeOperation Operation => (this as IConvertableToPipelineNode).NodeMain;
|
||||
|
||||
/**/
|
||||
|
||||
internal SemaphoreSlim RunningStat
|
||||
{
|
||||
get => runningStat;
|
||||
}
|
||||
internal SemaphoreSlim RunningStat => runningStat;
|
||||
|
||||
public void AddNode(PipelineNode node, bool isNative)
|
||||
public void AddNode(
|
||||
PipelineNode node,
|
||||
bool isNative
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(node);
|
||||
node.IsNative = isNative;
|
||||
@@ -161,7 +128,10 @@ namespace StgSharp.PipeLine
|
||||
_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)) {
|
||||
throw new InvalidOperationException("Label has exist in scheduler.");
|
||||
@@ -171,7 +141,9 @@ namespace StgSharp.PipeLine
|
||||
return node;
|
||||
}
|
||||
|
||||
public PipelineNode GetNode(PipelineNodeLabel label)
|
||||
public PipelineNode GetNode(
|
||||
PipelineNodeLabel label
|
||||
)
|
||||
{
|
||||
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);
|
||||
PipelineNodeOutPort p = _beginning.DefaultOut;
|
||||
p.Connect(port);
|
||||
}
|
||||
|
||||
public void LinkToInput(PipelineNodeInPort port, string inputPortName)
|
||||
public void LinkToInput(
|
||||
PipelineNodeInPort port,
|
||||
string inputPortName
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(port);
|
||||
PipelineNodeOutPort p = _beginning.DefineCertainOutputPort(inputPortName);
|
||||
@@ -197,7 +174,9 @@ namespace StgSharp.PipeLine
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetInput(params (string label, IPipeLineConnectionPayload arg)[] parameters)
|
||||
public void SetInput(
|
||||
params (string label, IPipeLineConnectionPayload arg)[] parameters
|
||||
)
|
||||
{
|
||||
_beginning.SetInputData(parameters);
|
||||
}
|
||||
@@ -211,7 +190,8 @@ namespace StgSharp.PipeLine
|
||||
|
||||
public bool TryGetAllNode(
|
||||
out List<List<PipelineNode>> mainThreadNodes,
|
||||
out List<List<PipelineNode>> concurrentNodes)
|
||||
out List<List<PipelineNode>> concurrentNodes
|
||||
)
|
||||
{
|
||||
if (_isAvailable)
|
||||
{
|
||||
@@ -224,7 +204,9 @@ namespace StgSharp.PipeLine
|
||||
return false;
|
||||
}
|
||||
|
||||
internal bool RequestNexConcurrentNode(out PipelineNode node)
|
||||
internal bool RequestNexConcurrentNode(
|
||||
out PipelineNode node
|
||||
)
|
||||
{
|
||||
int index, level;
|
||||
if (cLevel >= _concurrentNodes.Count)
|
||||
@@ -251,7 +233,9 @@ namespace StgSharp.PipeLine
|
||||
return true;
|
||||
}
|
||||
|
||||
internal bool RequestNextMainThreadNode(out PipelineNode node)
|
||||
internal bool RequestNextMainThreadNode(
|
||||
out PipelineNode node
|
||||
)
|
||||
{
|
||||
if (mtLevel >= _mainThreadNodes.Count)
|
||||
{
|
||||
@@ -280,7 +264,8 @@ namespace StgSharp.PipeLine
|
||||
|
||||
void IConvertableToPipelineNode.NodeMain(
|
||||
in Dictionary<string, PipelineNodeInPort> input,
|
||||
in Dictionary<string, PipelineNodeOutPort> output)
|
||||
in Dictionary<string, PipelineNodeOutPort> output
|
||||
)
|
||||
{
|
||||
PipeLineRunner.Run(this);
|
||||
PipelineNodeOutPort.SkipAll(output);
|
||||
|
||||
Reference in New Issue
Block a user