Imported Upstream version 4.3.2.467

Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
Xamarin Public Jenkins
2016-02-22 11:00:01 -05:00
parent f302175246
commit f3e3aab35a
4097 changed files with 122406 additions and 82300 deletions

View File

@ -14,7 +14,6 @@ namespace System.Runtime.Caching {
internal sealed class MemoryCacheStore : IDisposable {
const int INSERT_BLOCK_WAIT = 10000;
const int MAX_COUNT = Int32.MaxValue / 2;
const int MIN_COUNT = 10;
private Hashtable _entries;
private Object _entriesLock;
@ -140,7 +139,7 @@ namespace System.Runtime.Caching {
if (_disposed == 0) {
existingEntry = _entries[key] as MemoryCacheEntry;
// has it expired?
if (existingEntry != null && entry.UtcAbsExp <= DateTime.UtcNow) {
if (existingEntry != null && existingEntry.UtcAbsExp <= DateTime.UtcNow) {
toBeReleasedEntry = existingEntry;
toBeReleasedEntry.State = EntryState.RemovingFromCache;
existingEntry = null;
@ -300,21 +299,18 @@ namespace System.Runtime.Caching {
}
internal long TrimInternal(int percent) {
Dbg.Assert(percent <= 100, "percent <= 100");
int count = Count;
int toTrim = 0;
// do we need to drop a percentage of entries?
if (percent > 0) {
toTrim = (int)(((long)count * (long)percent) / 100L);
toTrim = (int)Math.Ceiling(((long)count * (long)percent) / 100D);
// would this leave us above MAX_COUNT?
int minTrim = count - MAX_COUNT;
if (toTrim < minTrim) {
toTrim = minTrim;
}
// would this put us below MIN_COUNT?
int maxTrim = count - MIN_COUNT;
if (toTrim > maxTrim) {
toTrim = maxTrim;
}
}
// do we need to trim?
if (toTrim <= 0 || _disposed == 1) {