Beispiel #1
0
        /// <summary>
        /// Run pipeline (asynchronously).
        /// </summary>
        /// <param name="descriptor">Replay descriptor.</param>
        /// <param name="clock">Clock to use (in the case of a shared scheduler - e.g. subpipeline).</param>
        /// <returns>Disposable used to terminate pipeline.</returns>
        internal virtual IDisposable RunAsync(ReplayDescriptor descriptor, Clock clock)
        {
            descriptor            = descriptor ?? ReplayDescriptor.ReplayAll;
            this.replayDescriptor = descriptor.Intersect(descriptor.UseOriginatingTime ? this.proposedOriginatingTimeInterval : this.proposedTimeInterval);

            this.completed.Reset();
            if (clock == null)
            {
                clock =
                    this.replayDescriptor.Interval.Left != DateTime.MinValue ?
                    new Clock(this.replayDescriptor.Start, 1 / this.replayDescriptor.ReplaySpeedFactor) :
                    new Clock(default(TimeSpan), 1 / this.replayDescriptor.ReplaySpeedFactor);
                this.scheduler.Start(clock, this.replayDescriptor.EnforceReplayClock);
            }

            // keep track of source components
            foreach (var component in this.components)
            {
                if (component.IsSource)
                {
                    lock (this.sourceComponents)
                    {
                        this.sourceComponents.Add(component);
                    }
                }
            }

            foreach (var component in this.components)
            {
                component.Start(this.replayDescriptor);
            }

            return(this);
        }
Beispiel #2
0
        /// <summary>
        /// Run pipeline (asynchronously).
        /// </summary>
        /// <param name="descriptor">Replay descriptor.</param>
        /// <returns>Disposable used to terminate pipeline.</returns>
        public IDisposable RunAsync(ReplayDescriptor descriptor)
        {
            descriptor            = descriptor ?? ReplayDescriptor.ReplayAll;
            this.replayDescriptor = descriptor.Intersect(descriptor.UseOriginatingTime ? this.proposedOriginatingTimeInterval : this.proposedTimeInterval);

            bool hasExplicitStart = this.replayDescriptor.Interval.Left != DateTime.MinValue;

            this.clock = hasExplicitStart ? new Clock(this.replayDescriptor.Start, 1 / this.replayDescriptor.ReplaySpeedFactor) : new Clock(default(TimeSpan), 1 / this.replayDescriptor.ReplaySpeedFactor);
            this.completed.Reset();
            this.scheduler.Start(this.clock, descriptor.EnforceReplayClock);

            // keep track of startable components
            foreach (var component in this.components)
            {
                if (component.IsStartable)
                {
                    lock (this.startableComponents)
                    {
                        this.startableComponents.Add(component);
                    }
                }
            }

            foreach (var component in this.components)
            {
                component.Activate(this.replayDescriptor);
            }

            return(this);
        }
Beispiel #3
0
        /// <summary>
        /// Run pipeline (asynchronously).
        /// </summary>
        /// <param name="descriptor">Replay descriptor.</param>
        /// <returns>Disposable used to terminate pipeline.</returns>
        public override IDisposable RunAsync(ReplayDescriptor descriptor)
        {
            var node = this.parent.GetOrCreateNode(this);

            node.Activate();

            // We are starting this subpipeline by activating its associated node in
            // the parent pipeline. Wait for activation to finish before returning.
            this.Scheduler.PauseForQuiescence(this.parent.ActivationContext);

            return(this);
        }
Beispiel #4
0
 /// <summary>
 /// Run pipeline (asynchronously).
 /// </summary>
 /// <param name="descriptor">Replay descriptor.</param>
 /// <returns>Disposable used to terminate pipeline.</returns>
 public override IDisposable RunAsync(ReplayDescriptor descriptor)
 {
     return(this.RunAsync(descriptor, this.parent.Clock));
 }
Beispiel #5
0
 /// <summary>
 /// Run pipeline (asynchronously).
 /// </summary>
 /// <param name="descriptor">Replay descriptor.</param>
 /// <returns>Disposable used to terminate pipeline.</returns>
 public virtual IDisposable RunAsync(ReplayDescriptor descriptor)
 {
     return(this.RunAsync(descriptor, null));
 }
Beispiel #6
0
 /// <summary>
 /// Run pipeline (synchronously).
 /// </summary>
 /// <param name="descriptor">Replay descriptor.</param>
 /// <param name="enableExceptionHandling">Whether to enable exception handling.</param>
 public void Run(ReplayDescriptor descriptor, bool enableExceptionHandling = false)
 {
     this.enableExceptionHandling = enableExceptionHandling;
     this.RunAsync(descriptor);
     this.WaitAll();
 }