public CakeMachine(CakeMachineSettings settings) { _cakes = new ConcurrentBag <Cake>(); var durationSettings = settings.DurationSettings; _prepareDuration = durationSettings.PrepareDuration; _cookDuration = durationSettings.CookDuration; _packageDuration = durationSettings.PackageDuration; _deliveryDuration = durationSettings.DeliveryDuration; var prepareMaxDegree = settings.ParallelismSettings.PrepareMaxDegree; var cookMaxDegree = settings.ParallelismSettings.CookMaxDegree; var packageMaxDegree = settings.ParallelismSettings.PackageMaxDegree; _linkOptions = new DataflowLinkOptions { PropagateCompletion = true }; _prepareOptions = new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = prepareMaxDegree }; _cookOptions = new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = cookMaxDegree }; _packageOptions = new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = packageMaxDegree }; var reportingSettings = settings.ReportingSettings; if (!(reportingSettings?.IsEnabled ?? false)) { return; } _reportingTimer = new ReportingTimer(reportingSettings.ReportInterval, OnReportingTimerEvent); }
public CakeService(DurationSettings settings) { _cakes = new ConcurrentBag <Cake>(); _durationSettingsModel = settings; _prepareOptions = new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = settings.PrepareMaxDegree }; _cookOptions = new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = settings.CookMaxDegree }; _packageOptions = new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = settings.PackageMaxDegree }; _reportingTimer = new ReportingTimer(settings.ReportingDuration, OnReportingTimerEvent); }