private async Task <bool> TryRegisterNewExecutorInternalAsync(TaskPullerMetadata metadata, CancellationToken cancellation) { try { await _operationSemaphoreSlim.WaitAsync(cancellation).ConfigureAwait(false); } catch (OperationCanceledException) { return(false); } try { if (!_isFinalizing) { var key = metadata.TaskExecutorTypeId; if (_executorRegistry.ContainsKey(key)) { return(false); } HandleMetadataRegistration(metadata); _executorRegistry.Add(key, metadata); return(true); } return(false); } finally { _operationSemaphoreSlim.Release(); } }
private void HandleMetadataUnRegistration(TaskPullerMetadata metadata) { if (metadata != null) { metadata.TaskManagerCancellationToken = null; metadata.GlobalApproveNewExecutorCreationCriteriaInContext = null; } }
public async Task <bool> TryRegisterNewExecutorAsync(TaskPullerMetadata metadata, CancellationToken cancellation) { if (metadata.TaskExecutorTypeId == Constraint.DaemonExecutorId) { return(false); } return(await TryRegisterNewExecutorInternalAsync(metadata, cancellation).ConfigureAwait(false)); }
private void HandleMetadataRegistration(TaskPullerMetadata metadata) { if (metadata.TaskManagerCancellationToken != null) { throw new Exception("Metadata was already bind to an execution context"); } metadata.TaskManagerCancellationToken = _cts; metadata.GlobalApproveNewExecutorCreationCriteriaInContext = GlobalApproveNewExecutorCreationCriteria; }