Exemplo n.º 1
0
        /// <summary>
        /// Creates a processor set loaded with the provided processors.
        /// </summary>
        /// <remarks>
        /// <para>
        /// An empty processor set will be created if <paramref name="processors"/> is null
        /// or contains no processors.
        /// </para>
        /// </remarks>
        /// <param name="processors">The processors to include in the set.</param>
        /// <returns>The processor set</returns>
        public static ProcessorSet Create(INMGenProcessor[] processors)
        {
            INMGenProcessor[] lprocessors = ArrayUtil.Compress(processors);

            if (lprocessors == null)
            {
                lprocessors = new INMGenProcessor[0];
            }
            else if (lprocessors == processors)
            {
                lprocessors = (INMGenProcessor[])processors.Clone();
            }

            return(new ProcessorSet(lprocessors));
        }
        private ProcessorSet(INMGenProcessor[] processors) 
        {
            mProcessors = processors;

            PriorityComparer<INMGenProcessor> comp = 
                new PriorityComparer<INMGenProcessor>(true);

            System.Array.Sort(mProcessors, comp);

            mIsThreadSafe = true;  // This is correct.

            foreach (INMGenProcessor p in mProcessors)
            {
                mPreserveAssets |= p.PreserveAssets;

                if (!p.IsThreadSafe)
                    mIsThreadSafe = false;
            }
        }
        /// <summary>
        /// Creates a processor set loaded with the provided processors.
        /// </summary>
        /// <remarks>
        /// <para>
        /// An empty processor set will be created if <paramref name="processors"/> is null
        /// or contains no processors.
        /// </para>
        /// </remarks>
        /// <param name="processors">The processors to include in the set.</param>
        /// <returns>The processor set</returns>
        public static ProcessorSet Create(INMGenProcessor[] processors)
        {
            INMGenProcessor[] lprocessors = ArrayUtil.Compress(processors);

            if (lprocessors == null)
                lprocessors = new INMGenProcessor[0];
            else if (lprocessors == processors)
                lprocessors = (INMGenProcessor[])processors.Clone();

            return new ProcessorSet(lprocessors);
        }