You've already forked linux-packaging-mono
Imported Upstream version 5.10.0.47
Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
parent
88ff76fe28
commit
e46a49ecf1
@@ -6,13 +6,14 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading;
|
||||
|
||||
namespace System.Runtime.Caching {
|
||||
internal class MemoryCacheEntry: MemoryCacheKey {
|
||||
const byte EntryStateMask = 0x1f;
|
||||
|
||||
private Object _value;
|
||||
private DateTime _utcCreated;
|
||||
private int _state;
|
||||
// expiration
|
||||
private DateTime _utcAbsExp;
|
||||
private TimeSpan _slidingExp;
|
||||
@@ -69,8 +70,8 @@ namespace System.Runtime.Caching {
|
||||
}
|
||||
|
||||
internal EntryState State {
|
||||
get { return (EntryState)(_bits & EntryStateMask); }
|
||||
set { _bits = (byte)(((uint)_bits & ~(uint)EntryStateMask) | (uint)value); }
|
||||
get { return (EntryState)_state; }
|
||||
set { _state = (int)value; }
|
||||
}
|
||||
|
||||
internal byte UsageBucket {
|
||||
@@ -169,6 +170,10 @@ namespace System.Runtime.Caching {
|
||||
}
|
||||
}
|
||||
|
||||
internal bool CompareExchangeState(EntryState value, EntryState comparand) {
|
||||
return (Interlocked.CompareExchange(ref _state, (int)value, (int)comparand) == (int)comparand);
|
||||
}
|
||||
|
||||
// Associates this entry with an update sentinel. If this entry has a sliding expiration, we need to
|
||||
// touch the sentinel so that it doesn't expire.
|
||||
internal void ConfigureUpdateSentinel(MemoryCacheStore sentinelStore, MemoryCacheEntry sentinelEntry) {
|
||||
|
@@ -9,7 +9,6 @@ namespace System.Runtime.Caching {
|
||||
internal class MemoryCacheKey {
|
||||
private String _key;
|
||||
private int _hash;
|
||||
protected byte _bits;
|
||||
|
||||
internal int Hash { get { return _hash; } }
|
||||
internal String Key { get { return _key; } }
|
||||
|
@@ -38,23 +38,36 @@ namespace System.Runtime.Caching {
|
||||
// private members
|
||||
|
||||
private void AddToCache(MemoryCacheEntry entry) {
|
||||
|
||||
// add outside of lock
|
||||
if (entry != null) {
|
||||
if (entry.HasExpiration()) {
|
||||
_expires.Add(entry);
|
||||
if (entry == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.HasExpiration()) {
|
||||
_expires.Add(entry);
|
||||
}
|
||||
|
||||
if (entry.HasUsage()
|
||||
&& (!entry.HasExpiration() || entry.UtcAbsExp - DateTime.UtcNow >= CacheUsage.MIN_LIFETIME_FOR_USAGE)) {
|
||||
_usage.Add(entry);
|
||||
}
|
||||
|
||||
// One last sanity check to be sure we didn't fall victim to an Add ----
|
||||
if (!entry.CompareExchangeState(EntryState.AddedToCache, EntryState.AddingToCache)) {
|
||||
if (entry.InExpires()) {
|
||||
_expires.Remove(entry);
|
||||
}
|
||||
|
||||
if (entry.HasUsage()
|
||||
&& (!entry.HasExpiration() || entry.UtcAbsExp - DateTime.UtcNow >= CacheUsage.MIN_LIFETIME_FOR_USAGE)) {
|
||||
_usage.Add(entry);
|
||||
if (entry.InUsage()) {
|
||||
_usage.Remove(entry);
|
||||
}
|
||||
}
|
||||
|
||||
entry.State = EntryState.AddedToCache;
|
||||
entry.CallNotifyOnChanged();
|
||||
if (_perfCounters != null) {
|
||||
_perfCounters.Increment(PerfCounterName.Entries);
|
||||
_perfCounters.Increment(PerfCounterName.Turnover);
|
||||
}
|
||||
entry.CallNotifyOnChanged();
|
||||
if (_perfCounters != null) {
|
||||
_perfCounters.Increment(PerfCounterName.Entries);
|
||||
_perfCounters.Increment(PerfCounterName.Turnover);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,6 +304,7 @@ namespace System.Runtime.Caching {
|
||||
if (added) {
|
||||
AddToCache(entry);
|
||||
}
|
||||
|
||||
// Dev10 861163: Call Release after the new entry has been completely added so
|
||||
// that the CacheItemRemovedCallback can take a dependency on the newly inserted item.
|
||||
if (existingEntry != null) {
|
||||
|
Reference in New Issue
Block a user