Giter Club home page Giter Club logo

Comments (5)

AuMilliat avatar AuMilliat commented on September 1, 2024

Few modifications to get it works with a real case:

In Subpipline.cs

 public override void Dispose()
 {
     this.Stop(this.parentPipeline.GetCurrentTime(), true);
     this.DisposeComponents();
     this.parentPipeline.RemoveSubpipline(this);
     this.DiagnosticsCollector?.PipelineDisposed(this);
 }

In Pipline.cs

 internal bool RemoveSubpipline(Subpipeline subpipeline)
 {
     PipelineElement node = this.components.FirstOrDefault(c => c.StateObject == subpipeline);
     if (node == null)
     {
         return false;
     }

     if (!subpipeline.IsCompleted)
     {
         throw new InvalidOperationException($"Subpipeline is still running, it can't be removed from parent pipeline.");
     }

     List<PipelineElement> list = subpipeline.Components.ToList();
     list.Add(node);
     SynchronizationLock locker = new SynchronizationLock(this, true);
     this.scheduler.Freeze(locker);
     this.components = new ConcurrentQueue<PipelineElement>(this.components.Where(x => !list.Contains(x)));
     this.DiagnosticsCollector?.PipelineElementDisposed(this, node);
     locker.Release();
     return true;
 }

It probably still needs some improvements (DiagnosticsCollector).

from psi.

sandrist avatar sandrist commented on September 1, 2024

Hello, can you explain a bit more about your use case which would benefit from stopping and resuming subpipelines? Pausing, stopping, and resuming (sub)pipelines mid-process is a bit tricky given the way the system has been designed so far. Take a look at the long discussion in issue #256.

Another idea is to look into the use of the Parallel Operator. This operator already has the ability to dynamically construct and tear down subpipelines according to the data flowing into it, and it's pretty extensible. It was carefully designed to do this in the right way. I wonder if you could use Parallel to achieve the goals in your scenario?

from psi.

AuMilliat avatar AuMilliat commented on September 1, 2024

Thanks for the answers and the information.

What we want to do is to be able to remove a subpipeline without disposing the parent pipeline. At the moment, in our setup we have a dedicated computer for handling a kinect azure camera. We’ve done a WPF application that stream the data through the RendezVous system. Our next step is to able able to start and stop the kinect streaming with a command from a remote computer (as we might have configuration modification).
What we try to have is a pipeline that own RemoteClockImporter and a RemoteExporter for diagnostics. And have subpipeline for each RendezVous.Process that can be created and disposed while the pipline is still running.

We was looking at independents pipelines with Connector for the clock and the diagnostics. But maybe the ParallelOperator is the way to go, thanks!

from psi.

AuMilliat avatar AuMilliat commented on September 1, 2024

I've checked the ParallelOperator, it does not seems to work on my case as I have different type of streams. I may have found a better solution for my use case by adding a method in the Pipeline class :

        /// <summary>
        /// Create new pipeline setting time offset and diagnostics collector from given pipeline.
        /// </summary>
        /// <param name="pipeline">Pipeline to retrieve time offset and diagonistic configuration.</param>
        /// <param name="name">Pipeline name.</param>
        /// <param name="threadCount">Number of threads.</param>
        /// <param name="allowSchedulingOnExternalThreads">Whether to allow scheduling on external threads.</param>
        /// <param name="enableDiagnostics">Indicates whether to enable collecting and publishing diagnostics information on the Pipeline.Diagnostics stream.</param>
        /// <returns>Created pipeline.</returns>
        public static Pipeline CreateSynchedPipeline(
            Pipeline pipeline,
            string name = null,
            int threadCount = 0,
            bool allowSchedulingOnExternalThreads = false,
            bool enableDiagnostics = false)
        {
            Pipeline newPipeline = new Pipeline(name == null ? $"Synched|{pipeline.Name}" : name, pipeline.defaultDeliveryPolicy, threadCount, allowSchedulingOnExternalThreads);
            newPipeline.VirtualTimeOffset = pipeline.VirtualTimeOffset;
            newPipeline.DiagnosticsCollector = enableDiagnostics ? pipeline.DiagnosticsCollector : null;
            newPipeline.DiagnosticsConfiguration = pipeline.DiagnosticsConfiguration;
            return newPipeline;
        }

from psi.

AuMilliat avatar AuMilliat commented on September 1, 2024

I'm closing this issue, the implementation is available at https://github.com/SaacPSI/psi/tree/Pipline%2BExporter.

from psi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.