bool Handle(TemplateTypeParameter p, ISemantic arg)
        {
            // if no argument given, try to handle default arguments
            if (arg == null)
            {
                return(TryAssignDefaultType(p));
            }

            // If no spezialization given, assign argument immediately
            if (p.Specialization == null)
            {
                return(Set(p, arg, 0));
            }

            bool handleResult = HandleDecl(null, p.Specialization, arg);

            if (!handleResult)
            {
                return(false);
            }

            // Apply the entire argument to parameter p if there hasn't been no explicit association yet
            TemplateParameterSymbol tps;

            if (!TargetDictionary.TryGetValue(p, out tps) || tps == null)
            {
                TargetDictionary[p] = new TemplateParameterSymbol(p, arg);
            }

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Unpostpone target in the case when it didn't successfuly consume a message.
        /// </summary>
        public void UnpostponeTargetNotConsumed(ITargetBlock <T> targetBlock)
        {
            Target target;

            if (!TargetDictionary.TryGetValue(targetBlock, out target))
            {
                return;
            }

            unpostponedTargets.Enqueue(Tuple.Create(target,
                                                    new DataflowMessageHeader()));

            target.Postponed.Value = false;
            target.Reserved.Value  = false;
        }
Esempio n. 3
0
        /// <summary>
        /// Unpostpones the given target.
        /// </summary>
        /// <param name="targetBlock">Target to unpostpone.</param>
        /// <param name="messageConsumed">Did the target consume an item?</param>
        public void UnpostponeTarget(ITargetBlock <T> targetBlock, bool messageConsumed)
        {
            Target target;

            if (!TargetDictionary.TryGetValue(targetBlock, out target))
            {
                return;
            }

            if (messageConsumed)
            {
                target.MessageSent();
            }
            unpostponedTargets.Enqueue(target);

            target.Postponed.Value = false;
        }