public InternalEnumerator(IEnumerator <T> source, InternalEnumerable controllingEnumerable, Shared <long> index)
 {
     m_source  = source;
     m_current = default(KeyValuePair <long, T>);
     m_controllingEnumerable = controllingEnumerable;
     m_index = index;
 }
Example #2
0
        // Produces a list of "numPartitions" IEnumerators that can each be
        // used to traverse the underlying collection in a thread-safe manner.
        // This will return a static number of enumerators, as opposed to
        // GetDynamicPartitions(), the result of which can be used to produce
        // any number of enumerators.
        public override IList <IEnumerator <T> > GetPartitions(int numPartitions)
        {
            if (numPartitions < 1)
            {
                throw new ArgumentOutOfRangeException("NumPartitions");
            }

            List <IEnumerator <T> > list = new List <IEnumerator <T> >(numPartitions);

            // Since we are doing static partitioning, create an InternalEnumerable with reference
            // counting of spawned InternalEnumerators turned on.  Once all of the spawned enumerators
            // are disposed, dynamicPartitions will be disposed.
            var dynamicPartitions = new InternalEnumerable(m_referenceEnumerable.GetEnumerator(), true);

            for (int i = 0; i < numPartitions; i++)
            {
                list.Add(dynamicPartitions.GetEnumerator());
            }

            return(list);
        }
Example #3
0
 public InternalEnumerator(IEnumerator <T> source, InternalEnumerable controllingEnumerable)
 {
     m_source  = source;
     m_current = default(T);
     m_controllingEnumerable = controllingEnumerable;
 }