Exemplo n.º 1
0
        // Token: 0x060071C8 RID: 29128 RVA: 0x00178C3C File Offset: 0x00176E3C
        public LocalTimeCostHandle StartLocal(Action <CostHandle> onRelease, string callerInfo, TimeSpan preCharge)
        {
            LocalTimeCostHandle result = null;

            lock (this.SyncRoot)
            {
                this.casTokenBucket.Increment();
                result = new LocalTimeCostHandle(this, onRelease, string.Format("Caller: {0}, ThreadID: {1}, PreCharge: {2}ms", callerInfo, Environment.CurrentManagedThreadId, preCharge.TotalMilliseconds), preCharge);
            }
            return(result);
        }
Exemplo n.º 2
0
 protected override void StartLocalImpl(string callerInfo, TimeSpan preCharge)
 {
     if (base.LocalCostHandle != null)
     {
         LocalTimeCostHandle localCostHandle = base.LocalCostHandle;
         ExTraceGlobals.ClientThrottlingTracer.TraceDebug <BudgetKey>((long)this.GetHashCode(), "[PswsBudgetWrapper.StartLocalImpl] BudgetWrapper of user \"{0}\" is accessed by multi-thread concurrently.", localCostHandle.Budget.Owner);
         base.LocalCostHandle = null;
         localCostHandle.Dispose();
     }
     base.StartLocalImpl(callerInfo, preCharge);
 }
Exemplo n.º 3
0
 public void EndLocal()
 {
     this.CheckExpired();
     lock (this.instanceLock)
     {
         if (this.localCostHandle != null)
         {
             LocalTimeCostHandle localTimeCostHandle = this.localCostHandle;
             this.localCostHandle = null;
             localTimeCostHandle.Dispose();
         }
     }
 }
Exemplo n.º 4
0
 // Token: 0x060071E3 RID: 29155 RVA: 0x00179324 File Offset: 0x00177524
 protected virtual void AccountForCostHandle(CostHandle costHandle)
 {
     if (costHandle.CostType == CostType.CAS)
     {
         TimeSpan            timeSpan            = costHandle.PreCharge;
         LocalTimeCostHandle localTimeCostHandle = costHandle as LocalTimeCostHandle;
         bool flag = localTimeCostHandle != null && localTimeCostHandle.ReverseBudgetCharge;
         if (flag)
         {
             ExTraceGlobals.ClientThrottlingTracer.TraceDebug((long)this.GetHashCode(), "[Budget.AccountForCostHandle] Not charging budget for CAS time per protocol's request.");
             timeSpan += TimeProvider.UtcNow - costHandle.StartTime;
         }
         this.casTokenBucket.Decrement(timeSpan, flag);
         this.percentileUsage.AddUsage((int)(TimeProvider.UtcNow - costHandle.StartTime).TotalMilliseconds);
     }
 }
Exemplo n.º 5
0
        private void CalculateElapsedTime(CostHandle costHandle)
        {
            LocalTimeCostHandle localTimeCostHandle = costHandle as LocalTimeCostHandle;

            if (localTimeCostHandle != null)
            {
                TimeSpan unaccountedForTime = localTimeCostHandle.UnaccountedForTime;
                if (unaccountedForTime > TimeSpan.Zero)
                {
                    T t = this.GetInnerBudget();
                    if (t.CasTokenBucket.GetBalance() < 0f)
                    {
                        this.microDelayWorthyWork += unaccountedForTime;
                    }
                    else
                    {
                        this.microDelayWorthyWork = TimeSpan.Zero;
                    }
                    this.allWork += unaccountedForTime;
                    WorkloadManagementLogger.SetBudgetUsage(unaccountedForTime, null, null);
                }
            }
        }