예제 #1
0
        /// <summary>
        /// Schedules a node for execution in the thread pool.
        /// </summary>
        /// <param name='node'>Node of the graph to put into execution.</param>
        private void ScheduleForExecution(ExecutionNode node)
        {
            Interlocked.Increment(ref _activeNodes);

            StartTask(delegate {
                try {
                    this.VisitNode(node.Name);

                    foreach (ExecutionNode dependantNode in node.DependantNodes)
                    {
                        if (dependantNode.ResolvePrerequisite())
                        {
                            this.ScheduleForExecution(dependantNode);
                        }
                    }
                }
                catch (Exception e) {
                    lock (this._exceptions) {
                        this._exceptions.Add(e);
                    }
                }

                if (Interlocked.Decrement(ref _activeNodes) == 0)
                {
                    this._finished.Set();
                }
            });
        }
예제 #2
0
 /// <summary>
 /// Registers a node as a leaf node (no prerequisites).
 /// </summary>
 /// <param name='node'>Node to be registered as a leaf.</param>
 public void RegisterLeafNode(ExecutionNode node)
 {
     if (!this._leaves.Contains(node))
     {
         this._leaves.Add(node);
     }
 }
예제 #3
0
        /// <summary>
        /// Gets the node with the given name. Creates a new node, if there is no node with the given name in the graph.
        /// </summary>
        /// <returns>
        /// An instance of <see cref="ExecutionNode"/> class.
        /// </returns>
        /// <param name='name'>
        /// Name of the node to return.
        /// </param>
        public ExecutionNode GetNode(string name)
        {
            ExecutionNode result;

            if (this._nodes.TryGetValue(name, out result))
            {
                return(result);
            }

            result            = new ExecutionNode(name);
            this._nodes[name] = result;

            return(result);
        }
예제 #4
0
        /// <summary>
        /// Schedules a node for execution in the thread pool.
        /// </summary>
        /// <param name='node'>Node of the graph to put into execution.</param>
        private void ScheduleForExecution(ExecutionNode node) {
            Interlocked.Increment(ref _activeNodes);

            StartTask(delegate {
                try {
                    this.VisitNode(node.Name);

                    foreach (ExecutionNode dependantNode in node.DependantNodes) {
                        if (dependantNode.ResolvePrerequisite()) {
                            this.ScheduleForExecution(dependantNode);
                        }
                    }
                }
                catch (Exception e) {
                    lock (this._exceptions) {
                        this._exceptions.Add(e);
                    }
                }

                if (Interlocked.Decrement(ref _activeNodes) == 0) {
                    this._finished.Set();
                }
            });
        }
예제 #5
0
 /// <summary>
 /// Registers a node as a leaf node (no prerequisites).
 /// </summary>
 /// <param name='node'>Node to be registered as a leaf.</param>
 public void RegisterLeafNode(ExecutionNode node) {
     if (!this._leaves.Contains(node)) {
         this._leaves.Add(node);
     }
 }
예제 #6
0
        /// <summary>
        /// Gets the node with the given name. Creates a new node, if there is no node with the given name in the graph.
        /// </summary>
        /// <returns>
        /// An instance of <see cref="ExecutionNode"/> class.
        /// </returns>
        /// <param name='name'>
        /// Name of the node to return.
        /// </param>
        public ExecutionNode GetNode(string name) {
            ExecutionNode result;

            if (this._nodes.TryGetValue(name, out result)) {
                return result;
            }

            result = new ExecutionNode(name);
            this._nodes[name] = result;

            return result;
        }
예제 #7
0
 /// <summary>
 /// Registers a dependant node for the current node. Implicitly registers current node as prerequisite for the dependant node.
 /// </summary>
 /// <param name='node'>Reference to the dependant node to connect with the current node.</param>
 public void RegisterDependantNode(ExecutionNode node)
 {
     _dependantNodes.Add(node);
     node.AddPrerequisite();
 }
예제 #8
0
 /// <summary>
 /// Registers a dependant node for the current node. Implicitly registers current node as prerequisite for the dependant node.
 /// </summary>
 /// <param name='node'>Reference to the dependant node to connect with the current node.</param>
 public void RegisterDependantNode(ExecutionNode node) {
     _dependantNodes.Add(node);
     node.AddPrerequisite();
 }