public async ValueTask <bool> RemoveProcessor(HttpIoProcessorBase <THost, TContext> processor, CancellationToken token)
        {
            if (RemoveFromList(processor))
            {
                await StopHost(token).ConfigureAwait(false);

                return(true);
            }

            return(false);
        }
        public async ValueTask AddProcessor(HttpIoProcessorBase <THost, TContext> processor, CancellationToken token)
        {
            if (AddToList(processor))
            {
                try
                {
                    await StartHost(token).ConfigureAwait(false);
                }
                catch
                {
                    RemoveFromList(processor);

                    throw;
                }
            }
        }
        private bool AddToList(HttpIoProcessorBase <THost, TContext> processor)
        {
            ImmutableList <HttpIoProcessorBase <THost, TContext> > preVal, newVal;

            do
            {
                preVal = Processors;

                if (preVal.Contains(processor))
                {
                    return(false);
                }

                newVal = preVal.Add(processor);
            }while (Interlocked.CompareExchange(ref _processors, newVal, preVal) != preVal);

            return(preVal.Count == 0);
        }
        private bool RemoveFromList(HttpIoProcessorBase <THost, TContext> processor)
        {
            ImmutableList <HttpIoProcessorBase <THost, TContext> > preVal, newVal;

            do
            {
                preVal = Processors;

                var index = preVal.IndexOf(processor);
                if (index < 0)
                {
                    return(false);
                }

                newVal = preVal.RemoveAt(index);
            }while (Interlocked.CompareExchange(ref _processors, newVal, preVal) != preVal);

            return(newVal.Count == 0);
        }