/// <summary>Constructor.</summary>
        /// <param name="numThreads">
        /// -- if less than or equal to 0, then automatically determine the number
        /// of threads. Otherwise, the size of the underlying threadpool.
        /// </param>
        /// <param name="processor"/>
        /// <param name="orderResults">
        /// -- If true, return results in the order submitted. Otherwise, return results
        /// as they become available.
        /// </param>
        public MulticoreWrapper(int numThreads, IThreadsafeProcessor <I, O> processor, bool orderResults)
        {
            // Which id was the last id returned.  Only meaningful in the case
            // of a queue where output order matters.
            //  private final ExecutorCompletionService<Integer> queue;
            nThreads          = numThreads <= 0 ? Runtime.GetRuntime().AvailableProcessors() : numThreads;
            this.orderResults = orderResults;
            outputQueue       = new ConcurrentHashMap <int, O>(2 * nThreads);
            threadPool        = BuildThreadPool(nThreads);
            //    queue = new ExecutorCompletionService<Integer>(threadPool);
            idleProcessors = new ArrayBlockingQueue <int>(nThreads, false);
            callback       = null;
            // Sanity check: Fixed thread pool so prevent timeouts.
            // Default should be false
            threadPool.AllowCoreThreadTimeOut(false);
            threadPool.PrestartAllCoreThreads();
            // Setup the processors, one per thread
            IList <IThreadsafeProcessor <I, O> > procList = new List <IThreadsafeProcessor <I, O> >(nThreads);

            procList.Add(processor);
            idleProcessors.Add(0);
            for (int i = 1; i < nThreads; ++i)
            {
                procList.Add(processor.NewInstance());
                idleProcessors.Add(i);
            }
            processorList = Java.Util.Collections.UnmodifiableList(procList);
        }
 internal CRFLogConditionalObjectiveFunctionWithDropout(int[][][][] data, int[][] labels, int window, IIndex <string> classIndex, IList <IIndex <CRFLabel> > labelIndices, int[] map, string priorType, string backgroundSymbol, double sigma, double[]
                                                        [][][] featureVal, double delta, double dropoutScale, int multiThreadGrad, bool dropoutApprox, double unsupDropoutScale, int[][][][] unsupDropoutData)
     : base(data, labels, window, classIndex, labelIndices, map, priorType, backgroundSymbol, sigma, featureVal, multiThreadGrad)
 {
     dropoutPriorThreadProcessor = new _IThreadsafeProcessor_42(this);
     //TODO(Mengqiu) Need to figure out what to do with dataDimension() in case of
     // mixed supervised+unsupervised data for SGD (AdaGrad)
     this.delta                  = delta;
     this.dropoutScale           = dropoutScale;
     this.dropoutApprox          = dropoutApprox;
     dropoutPriorGradTotal       = Empty2D();
     this.unsupDropoutStartIndex = data.Length;
     this.unsupDropoutScale      = unsupDropoutScale;
     if (unsupDropoutData != null)
     {
         this.totalData = new int[data.Length + unsupDropoutData.Length][][][];
         for (int i = 0; i < data.Length; i++)
         {
             this.totalData[i] = data[i];
         }
         for (int i_1 = 0; i_1 < unsupDropoutData.Length; i_1++)
         {
             this.totalData[i_1 + unsupDropoutStartIndex] = unsupDropoutData[i_1];
         }
     }
     else
     {
         this.totalData = data;
     }
     InitEdgeLabels();
     InitializeDataFeatureHash();
 }
 public CallableJob(I item, int itemId, IThreadsafeProcessor <I, O> processor, int processorId, MulticoreWrapper.IJobCallback <O> callback)
 {
     this.item        = item;
     this.itemId      = itemId;
     this.processor   = processor;
     this.processorId = processorId;
     this.callback    = callback;
 }
 public InterruptibleMulticoreWrapper(int numThreads, IThreadsafeProcessor <I, O> processor, bool orderResults, long timeout)
     : base(numThreads, processor, orderResults)
 {
     this.timeout = timeout;
 }
 /// <summary>Constructor.</summary>
 /// <param name="nThreads">
 /// If less than or equal to 0, then automatically determine the number
 /// of threads. Otherwise, the size of the underlying threadpool.
 /// </param>
 /// <param name="processor"/>
 public MulticoreWrapper(int nThreads, IThreadsafeProcessor <I, O> processor)
     : this(nThreads, processor, true)
 {
 }