daily update on 20240427 by nitload youmu
This commit is contained in:
@@ -34,6 +34,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Logic
|
||||
@@ -44,24 +45,28 @@ namespace StgSharp.Logic
|
||||
|
||||
public abstract class BluePaintNode
|
||||
{
|
||||
|
||||
private BluePaintNodeAction mainOperation;
|
||||
|
||||
private BluePaint local;
|
||||
private bool survivalTask;
|
||||
|
||||
private Dictionary<string, BluePaintPipeline> inputInterfaces;
|
||||
private Dictionary<string, BluePaintPipeline> outputInterface;
|
||||
|
||||
private bool running;
|
||||
|
||||
private string name;
|
||||
private Task mainTask;
|
||||
|
||||
internal Dictionary<string, BluePaintPipeline> InputInterfaces => inputInterfaces;
|
||||
internal Dictionary<string, BluePaintPipeline> OutputInterface => outputInterface;
|
||||
|
||||
internal BluePaintNode(string name, bool isTaskSurvival)
|
||||
{
|
||||
this.name = name;
|
||||
SurvivalTask = isTaskSurvival;
|
||||
SurvivalTask = isTaskSurvival;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected BluePaintNode(string name, BluePaintNodeAction operation)
|
||||
{
|
||||
this.name = name;
|
||||
@@ -75,35 +80,35 @@ namespace StgSharp.Logic
|
||||
|
||||
public void Run()
|
||||
{
|
||||
if (survivalTask)
|
||||
foreach (var item in inputInterfaces)
|
||||
{
|
||||
if (mainTask == null)
|
||||
{
|
||||
mainTask = new Task(
|
||||
() =>
|
||||
{
|
||||
while (local.IsRunning)
|
||||
{
|
||||
mainOperation(in inputInterfaces, in outputInterface);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return;
|
||||
item.Value.WaitForStart();
|
||||
}
|
||||
mainOperation(in inputInterfaces, in outputInterface);
|
||||
}//--------------------------------- end of class -----------------------------
|
||||
}
|
||||
|
||||
public class BluePaintPipeline
|
||||
{
|
||||
|
||||
private Barrier formerCompleteBarrier;
|
||||
private SemaphoreSlim formerCompleteSemaphore;
|
||||
|
||||
private BluePaintPipelineArgs args;
|
||||
|
||||
public BluePaintPipeline()
|
||||
{
|
||||
formerCompleteSemaphore = new SemaphoreSlim(initialCount: 0,maxCount:1);
|
||||
}
|
||||
|
||||
public void CompleteAndWriteData(BluePaintPipelineArgs args)
|
||||
{
|
||||
formerCompleteBarrier.SignalAndWait();
|
||||
formerCompleteSemaphore.Release();
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public void WaitForStart()
|
||||
{
|
||||
formerCompleteSemaphore.Release();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user