internal override async Task CreateNewTaskExecutor(CancellationToken token)
        {
            try
            {
                if (await TryAllocateNewTaskExecutorIndexAsync(token).ConfigureAwait(false))
                {
                    TaskPuller puller = null;
                    try
                    {
                        puller = ExecutorActivator();
                    }
                    catch (Exception e)
                    {
                        ExecutorActivationException?.Invoke(this, e);
                        Interlocked.Decrement(ref RunningExecutorCounter);
                        return;
                    }

                    LinkNewExecutor(puller);
                    await puller.PullTaskAsync(token).ConfigureAwait(false);

                    puller?.Dispose();
                }
            }
            catch (Exception e)
            {
                PullerExecutionException?.Invoke(this, e);
            }
        }
Esempio n. 2
0
        internal override async Task CreateNewTaskExecutor(CancellationToken token)
        {
            IncrementExecutorCounter();
            try
            {
                TaskSubscriber <T> subscriber = null;
                try
                {
                    subscriber = ExecutorActivator();
                }
                catch (Exception e)
                {
                    ExecutorActivationException?.Invoke(this, e);
                    return;
                }
                LinkNewExecutor(subscriber);
                SubscriberExecutionStarting?.Invoke(subscriber);
                await subscriber.StartSubscribe().ConfigureAwait(false);

                SubscriberFinalized?.Invoke(subscriber);
                subscriber?.Dispose();
            }
            catch (Exception e)
            {
                SubscriberExecutionException?.Invoke(this, e);
            }
            finally
            {
                DecrementExecutorCounter();
            }
        }