예제 #1
0
        /// <summary>Adds a target to the registry.</summary>
        /// <param name="target">The target to add.</param>
        /// <param name="linkOptions">The link options.</param>
        internal void Add(ref ITargetBlock <T> target, DataflowLinkOptions linkOptions)
        {
            Contract.Requires(target != null, "The target that is supposed to be linked must not be null.");
            Contract.Requires(linkOptions != null, "The link options must not be null.");

            LinkedTargetInfo targetInfo;

            // If the target already exists in the registry, replace it with a new NopLinkPropagator to maintain uniqueness
            if (_targetInformation.TryGetValue(target, out targetInfo))
            {
                target = new NopLinkPropagator(_owningSource, target);
            }

            // Add the target to both stores, the list and the dictionary, which are used for different purposes
            var node = new LinkedTargetInfo(target, linkOptions);

            AddToList(node, linkOptions.Append);
            _targetInformation.Add(target, node);

            // Increment the optimization counter if needed
            Contract.Assert(_linksWithRemainingMessages >= 0, "_linksWithRemainingMessages must be non-negative at any time.");
            if (node.RemainingMessages > 0)
            {
                _linksWithRemainingMessages++;
            }
#if FEATURE_TRACING
            DataflowEtwProvider etwLog = DataflowEtwProvider.Log;
            if (etwLog.IsEnabled())
            {
                etwLog.DataflowBlockLinking(_owningSource, target);
            }
#endif
        }
예제 #2
0
 /// <summary>Initializes the debug view.</summary>
 /// <param name="passthrough">The passthrough to view.</param>
 public DebugView(NopLinkPropagator passthrough)
 {
     Contract.Requires(passthrough != null, "Need a propagator with which to construct the debug view.");
     _passthrough = passthrough;
 }
예제 #3
0
 /// <summary>Initializes the debug view.</summary>
 /// <param name="passthrough">The passthrough to view.</param>
 public DebugView(NopLinkPropagator passthrough)
 {
     Debug.Assert(passthrough != null, "Need a propagator with which to construct the debug view.");
     _passthrough = passthrough;
 }