// The GRPC service will use this to enqueue and notify the main // loop of new incoming work. private void EnqueueWorkload(IRenderServerWorkload workload) { lock (queue_) { queue_.Enqueue(workload); Monitor.Pulse(queue_); } }
private void ProcessCurrentWorkload() { current_workload_.ProcessWorkload(); if (current_workload_.WorkloadDone()) { current_workload_ = null; } }
// The RenderServer is a ImageBatchConsumer, when the Recorder is done // it will send a batch here. Pass it to the current workload if it is // a ImageBatchConsumer too. public void ConsumeImageBatch(RenderBatch batch) { if (current_workload_ != null && current_workload_ is IImageBatchConsumer) { (current_workload_ as IImageBatchConsumer).ConsumeImageBatch(batch); if (current_workload_.WorkloadDone()) { current_workload_ = null; } } else { Logger.Warning("RenderServer::ConsumeImageBatch::Unexpected image batch consume call."); } }
// Main server loop. Process current workload, or if it is done // try to get a next one. public void ProcessRequests() { if (current_workload_ != null) { ProcessCurrentWorkload(); } else { IRenderServerWorkload next_workload = GetNextWorkload(); if (next_workload != null) { InitializeNewWorkload(next_workload); ProcessCurrentWorkload(); } } }
private void InitializeNewWorkload(IRenderServerWorkload new_workload) { current_workload_ = new_workload; current_workload_.InitializeWorkload(); }