public Task HandleQueueDistributionChangeNotification() { latestRingNotificationSequenceNumber++; int notificationSeqNumber = latestRingNotificationSequenceNumber; Log(ErrorCode.PersistentStreamPullingManager_04, "Got QueueChangeNotification number {0} from the queue balancer. managerState = {1}", notificationSeqNumber, managerState); if (managerState == RunState.AgentsStopped) { return(Task.CompletedTask); // if agents not running, no need to rebalance the queues among them. } return(nonReentrancyGuarantor.AddNext(() => { // skip execution of an older/previous notification since already got a newer range update notification. if (notificationSeqNumber < latestRingNotificationSequenceNumber) { Log(ErrorCode.PersistentStreamPullingManager_05, "Skipping execution of QueueChangeNotification number {0} from the queue allocator since already received a later notification " + "(already have notification number {1}).", notificationSeqNumber, latestRingNotificationSequenceNumber); return Task.CompletedTask; } if (managerState == RunState.AgentsStopped) { return Task.CompletedTask; // if agents not running, no need to rebalance the queues among them. } return QueueDistributionChangeNotification(notificationSeqNumber); })); }
public async Task AsyncSerialExecutorTests_Small() { AsyncSerialExecutor executor = new AsyncSerialExecutor(); List <Task> tasks = new List <Task>(); operationsInProgress = 0; tasks.Add(executor.AddNext(() => Operation(1))); tasks.Add(executor.AddNext(() => Operation(2))); tasks.Add(executor.AddNext(() => Operation(3))); await Task.WhenAll(tasks); }
public async Task AsyncSerialExecutorTests_Small() { var executor = new AsyncSerialExecutor(); var tasks = new List <Task>(); _random = new SafeRandom(); _operationsInProgress = 0; tasks.Add(executor.AddNext(() => Operation(1))); tasks.Add(executor.AddNext(() => Operation(2))); tasks.Add(executor.AddNext(() => Operation(3))); await Task.WhenAll(tasks); }
public async Task AsyncSerialExecutorTests_SerialSubmit() { AsyncSerialExecutor executor = new AsyncSerialExecutor(); List <Task> tasks = new List <Task>(); for (int i = 0; i < 10; i++) { int capture = i; output.WriteLine("Submitting Task {0}.", capture); tasks.Add(executor.AddNext(() => Operation(capture))); } await Task.WhenAll(tasks); }
public async Task AsyncSerialExecutorTests_SerialSubmit() { AsyncSerialExecutor executor = new AsyncSerialExecutor(); random = new SafeRandom(); List <Task> tasks = new List <Task>(); for (int i = 0; i < 10; i++) { int capture = i; logger.Info("Submitting Task {0}.", capture); tasks.Add(executor.AddNext(() => Operation(capture))); } await Task.WhenAll(tasks); }
public async Task AsyncSerialExecutorTests_SerialSubmit() { var executor = new AsyncSerialExecutor(); _random = new SafeRandom(); var tasks = new List <Task>(); for (var i = 0; i < 10; i++) { var capture = i; _output.WriteLine("Submitting Task {0}.", capture); tasks.Add(executor.AddNext(() => Operation(capture))); } await Task.WhenAll(tasks); }
public async Task AsyncSerialExecutorTests_ParallelSubmit() { AsyncSerialExecutor executor = new AsyncSerialExecutor(); ConcurrentStack <Task> tasks = new ConcurrentStack <Task>(); List <Task> enqueueTasks = new List <Task>(); for (int i = 0; i < 10; i++) { int capture = i; enqueueTasks.Add( Task.Run(() => { output.WriteLine("Submitting Task {0}.", capture); tasks.Push(executor.AddNext(() => Operation(capture))); })); } await Task.WhenAll(enqueueTasks); await Task.WhenAll(tasks); }
public async Task UpdateStreamProviders(IDictionary <string, ProviderCategoryConfiguration> streamProviderConfigurations) { // Put the call into async serial executor so they will be executed in sequence. await nonReentrancyGuarantor.AddNext(() => Update(streamProviderConfigurations)); }