DeOps.DeOpsContext.AssignUploadSlots C# (CSharp) Method

AssignUploadSlots() public method

public AssignUploadSlots ( ) : void
return void
        public void AssignUploadSlots()
        {
            int activeTransfers = 0;
            OpCore next = null;

            Cores.SafeForEach(core =>
            {
                activeTransfers += core.Transfers.ActiveUploads;

                if (next == null || core.Transfers.NeedUploadWeight > next.Transfers.NeedUploadWeight)
                    next = core;
            });

            // max number of active transfers 15
            if (next == null || activeTransfers >= 15)
                return;

            // allocate a min of 5kb/s per transfer
            // allow a min of 2 transfers
            // if more than 10kb/s free, after accounting for upload speed allow another transfer
            // goal push transfers down to around 5kb/s, 30 secs to finish 256kb chunk
            if (activeTransfers < 2 || FastestUploadSpeed - 5 * activeTransfers > 10)
            {
                next.Transfers.NeedUploadWeight = 0; // do here so that if core is crashed/throwing exceptions - other cores can still u/l

                next.RunInCoreAsync(() => next.Transfers.StartUpload());
            }
        }