Exemple #1
0
        /// <summary>
        /// Creates an input receiver associated with the specified component object.
        /// </summary>
        /// <typeparam name="T">The type of messages accepted by this receiver</typeparam>
        /// <param name="owner">The component that owns the receiver. This is usually the state object that the receiver operates on.
        /// The receivers associated with the same owner are never executed concurrently.</param>
        /// <param name="action">The action to execute when a message is delivered to this receiver.</param>
        /// <param name="name">The debug name of the receiver</param>
        /// <param name="autoClone">If true, the receiver will clone the message before passing it to the action, which is then responsible for recycling it as needed (using receiver.Recycle)</param>
        /// <returns>A new receiver</returns>
        public Receiver <T> CreateReceiver <T>(object owner, Action <Message <T> > action, string name, bool autoClone = false)
        {
            PipelineElement node     = this.GetOrCreateNode(owner);
            var             receiver = new Receiver <T>(owner, action, node.SyncContext, this, autoClone);

            node.AddInput(name, receiver);
            return(receiver);
        }
Exemple #2
0
        // creates a custom receiver that does not enforce isolation on synchronous delivery
        private static Receiver <T> CreateNonIsolatedReceiver <T>(Pipeline pipeline, object owner, Action <Message <T> > action, string name)
        {
            PipelineElement node = pipeline.GetOrCreateNode(owner);

            // create custom receivers with a negative receiver id to ensure they do not clash with those created by the public Pipeline methods
            var receiver = new Receiver <T>(Interlocked.Decrement(ref lastReceiverId), name, node, owner, action, node.SyncContext, pipeline, enforceIsolation: false);

            node.AddInput(name, receiver);
            return(receiver);
        }