コード例 #1
0
        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();
            }
        }
コード例 #2
0
 private void HandleMetadataUnRegistration(TaskPullerMetadata metadata)
 {
     if (metadata != null)
     {
         metadata.TaskManagerCancellationToken = null;
         metadata.GlobalApproveNewExecutorCreationCriteriaInContext = null;
     }
 }
コード例 #3
0
        public async Task <bool> TryRegisterNewExecutorAsync(TaskPullerMetadata metadata, CancellationToken cancellation)
        {
            if (metadata.TaskExecutorTypeId == Constraint.DaemonExecutorId)
            {
                return(false);
            }

            return(await TryRegisterNewExecutorInternalAsync(metadata, cancellation).ConfigureAwait(false));
        }
コード例 #4
0
        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;
        }