示例#1
0
 internal DDMReaderRunner(DDMThreadedReader reader, DDMRecordFormat format, int reset, int skip, int total)
 {
     reader_     = reader;
     format_     = format.newCopy();
     resetIndex_ = reset;
     skipCount_  = skip;
     total_      = total;
 }
        /// <summary>
        /// Constructs a multi-threaded reader to process data being read from the specified file
        /// using the specified record format. </summary>
        /// <param name="format"> The record format to copy and give to each thread for it to pass to <seealso cref="#process process()"/>. </param>
        /// <param name="file"> The file being read. </param>
        /// <param name="numThreads"> The number of threads to use. This number is capped by the number of buffers in the file object, so
        /// that each thread always has at least one buffer to process, to avoid contention. Having more than one buffer per thread is fine.
        ///  </param>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public DDMThreadedReader(final DDMRecordFormat format, final DDMFile file, int numThreads)
        public DDMThreadedReader(DDMRecordFormat format, DDMFile file, int numThreads)
        {
            file_ = file;
            done_ = false;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int numBuffers = file.getBufferCount();
            int numBuffers = file.BufferCount;

            if (numThreads > numBuffers)
            {
                numThreads = numBuffers;
            }
            runners_ = new DDMReaderRunner[numThreads];
            threads_ = new Thread[numThreads];
            for (int i = 0; i < numThreads; ++i)
            {
                runners_[i] = new DDMReaderRunner(this, format, i, numThreads, numBuffers);
                threads_[i] = new Thread(runners_[i], "DDMThreadedReader-" + i);
                threads_[i].Start();
            }
        }
        /// <summary>
        /// Override this method with your own record processing logic.
        ///
        /// </summary>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public abstract void process(final DDMRecordFormat format, final DDMDataBuffer dataBuffer);
        public abstract void process(DDMRecordFormat format, DDMDataBuffer dataBuffer);