コード例 #1
0
        private ValueTask MakeIdle(ISpiffyWorker <T> worker)
        {
            idleWorkerQueue.Enqueue(worker);
            Interlocked.Increment(ref idleWorkers);

            return(new ValueTask());
        }
コード例 #2
0
        private async ValueTask MakeIdleOrCleanup(ISpiffyWorker <T> worker)
        {
            if (busyWorkerMap.TryRemove(worker.WorkerId, out ISpiffyWorker <T> oldWorker))
            {
                Interlocked.Decrement(ref activeWorkers);
            }

            if (worker.Lifetime == Short)
            {
                oldWorker.Dispose();
            }
            else
            {
                await MakeIdle(worker);
            }
        }
コード例 #3
0
        private ValueTask StartConsumerPipeline()
        {
            _ = Task.Run(async() =>
            {
                pipelineActive = true;

                while (await headNetworkBlock.OutputAvailableAsync(cancellationTokenSource.Token))
                {
                    TMessage msg             = await headNetworkBlock.ReceiveAsync(cancellationTokenSource.Token);
                    ISpiffyWorker <T> worker = await GetAvailableWorker();
                    _ = worker.RunAsync(msg);
                }

                pipelineActive = false;
            });

            return(new ValueTask());
        }
コード例 #4
0
 ValueTask ISpiffyContext <T> .Reclaim(ISpiffyWorker <T> spiffyWorker)
 => new ValueTask();
コード例 #5
0
 public override async ValueTask Reclaim(ISpiffyWorker <T> spiffyWorker)
 => await MakeIdleOrCleanup(spiffyWorker);