Base class for all concurrent training jobs.
コード例 #1
0
        /// <inheritdoc/>
        public void Perform(TrainingJob job)
        {

            lock (this)
            {
                if (!this.ready)
                {
                    throw new NeuralNetworkError(
                            "Performer is already performing a job.");
                }

                this.ready = false;
            }

            this.currentJob = job;

            PerformerTask task = new PerformerTask(this);
            EngineConcurrency.Instance.ProcessTask(task);
        }
コード例 #2
0
        /// <summary>
        /// Wait for a free performer. 
        /// </summary>
        /// <returns>The free performer.</returns>
        public IConcurrentTrainingPerformer WaitForFreePerformer(TrainingJob job)
        {
                IConcurrentTrainingPerformer result = null;

                while (result == null)
                {
                    foreach (IConcurrentTrainingPerformer performer in this.performers)
                    {
                        if (performer.Ready)
                        {
                            lock (this.accessLock)
                            {
                                performer.Perform(job);
                                result = performer;
                            }
                        }
                    }

                    if (result == null)
                    {
                        this.mightBeDone.WaitOne();
                    }
                }

                return result;
        }
コード例 #3
0
 /// <summary>
 /// Add a training job. 
 /// </summary>
 /// <param name="job">The training job to add.</param>
 public void AddTrainingJob(TrainingJob job)
 {
     lock (this.accessLock)
     {
         this.queue.Add(job);
     }
 }