/// <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); }
/// <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); } }
/// <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); }