Imported Upstream version 4.2.0.179

Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent 183bba2c9a
commit 6992685b86
7507 changed files with 90259 additions and 657307 deletions

View File

@@ -3,10 +3,8 @@ SUBDIRS =
include ../../build/rules.make
LIBRARY = System.Runtime.Caching.dll
LIB_MCS_FLAGS = -r:System.dll \
-r:System.Data.dll \
-r:System.Configuration.dll \
-r:System.Core.dll
LIB_REFS = System System.Data System.Configuration System.Core
LIB_MCS_FLAGS = -nowarn:414
TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)

View File

@@ -50,12 +50,16 @@ namespace System.Runtime.Caching
protected void Add (MemoryCacheEntry entry)
{
entries.Add (entry);
lock (entries) {
entries.Add (entry);
}
}
protected void Remove (MemoryCacheEntry entry)
{
entries.Remove (entry);
lock (entries) {
entries.Remove (entry);
}
}
protected int FlushItems (DateTime limit, CacheEntryRemovedReason reason, bool blockInsert, int count = int.MaxValue)

View File

@@ -40,13 +40,13 @@ namespace System.Runtime.Caching
{
}
public void Add (MemoryCacheEntry entry)
public new void Add (MemoryCacheEntry entry)
{
entry.ExpiresEntryRef = new ExpiresEntryRef ();
base.Add (entry);
}
public void Remove (MemoryCacheEntry entry)
public new void Remove (MemoryCacheEntry entry)
{
base.Remove (entry);
entry.ExpiresEntryRef = ExpiresEntryRef.INVALID;

View File

@@ -45,7 +45,7 @@ namespace System.Runtime.Caching {
{
}
public void Add (MemoryCacheEntry entry)
public new void Add (MemoryCacheEntry entry)
{
var now = DateTime.UtcNow;
if (now == prevDateTime)
@@ -61,7 +61,7 @@ namespace System.Runtime.Caching {
base.Add (entry);
}
public void Remove (MemoryCacheEntry entry)
public new void Remove (MemoryCacheEntry entry)
{
base.Remove (entry);
entry.UsageEntryRef = UsageEntryRef.INVALID;

View File

@@ -833,17 +833,9 @@ namespace MonoTests.System.Runtime.Caching
{
bool expired = false;
CacheEntryRemovedReason reason = CacheEntryRemovedReason.CacheSpecificEviction;
NameValueCollection config;
int sleepPeriod;
#if !DOTNET
config = new NameValueCollection ();
config.Add ("__MonoTimerPeriod", "1");
sleepPeriod = 1100;
#else
config = null;
sleepPeriod = 20100; // 20s is the .NET period - discovered by experimentation
#endif
var mc = new PokerMemoryCache ("MyCache", config);
int sleepPeriod = 1100;
var mc = new PokerMemoryCache ("MyCache");
var cip = new CacheItemPolicy ();
cip.RemovedCallback = (CacheEntryRemovedArguments args) => {
@@ -871,6 +863,7 @@ namespace MonoTests.System.Runtime.Caching
mc.Set ("key", "value", cip);
Thread.Sleep (sleepPeriod);
Assert.IsNull (mc.Get ("key"), "#A3-0");
Assert.IsTrue (expired, "#A3-1");
Assert.AreEqual (CacheEntryRemovedReason.Expired, reason, "#A3-2");
@@ -903,6 +896,10 @@ namespace MonoTests.System.Runtime.Caching
mc.Set ("key4", "value4", cip);
Thread.Sleep (sleepPeriod);
Assert.IsNull (mc.Get ("key1"), "#A4-1");
Assert.IsNull (mc.Get ("key2"), "#A4-2");
Assert.IsNull (mc.Get ("key3"), "#A4-3");
Assert.IsNotNull (mc.Get ("key4"), "#A4-4");
Assert.AreEqual (3, expiredCount, "#A4");
}
@@ -1235,11 +1232,7 @@ namespace MonoTests.System.Runtime.Caching
var config = new NameValueCollection ();
config["cacheMemoryLimitMegabytes"] = 0.ToString ();
config["physicalMemoryLimitPercentage"] = 100.ToString ();
config["__MonoEmulateOneCPU"] = true.ToString ();
// it appears that pollingInterval does nothing, so we set the Mono timer as well
config["pollingInterval"] = new TimeSpan (0, 0, 1).ToString ();
config["__MonoTimerPeriod"] = 1.ToString ();
using (var mc = new MemoryCache ("TestCacheShrink", config)) {
Assert.AreEqual (0, mc.GetCount (), "#CS1");
@@ -1263,6 +1256,9 @@ namespace MonoTests.System.Runtime.Caching
// wait for the cache thread to expire the short duration items, this will also shrink the size of the cache
global::System.Threading.Thread.Sleep (5 * 1000);
for (int i = 0; i < HEAP_RESIZE_SHORT_ENTRIES; i++) {
Assert.IsNull (mc.Get ("short-" + i), "#CS4-" + i);
}
Assert.AreEqual (HEAP_RESIZE_LONG_ENTRIES, mc.GetCount (), "#CS4");
// add some new items into the cache, this will grow the cache again
@@ -1280,11 +1276,7 @@ namespace MonoTests.System.Runtime.Caching
var config = new NameValueCollection ();
config["cacheMemoryLimitMegabytes"] = 0.ToString ();
config["physicalMemoryLimitPercentage"] = 100.ToString ();
config["__MonoEmulateOneCPU"] = true.ToString ();
// it appears that pollingInterval does nothing, so we set the Mono timer as well
config["pollingInterval"] = new TimeSpan (0, 0, 10).ToString ();
config["__MonoTimerPeriod"] = 10.ToString ();
using (var mc = new MemoryCache ("TestExpiredGetValues", config)) {
Assert.AreEqual (0, mc.GetCount (), "#EGV1");
@@ -1320,11 +1312,7 @@ namespace MonoTests.System.Runtime.Caching
var config = new NameValueCollection ();
config["cacheMemoryLimitMegabytes"] = 0.ToString ();
config["physicalMemoryLimitPercentage"] = 100.ToString ();
config["__MonoEmulateOneCPU"] = true.ToString ();
// it appears that pollingInterval does nothing, so we set the Mono timer as well
config["pollingInterval"] = new TimeSpan (0, 0, 1).ToString ();
config["__MonoTimerPeriod"] = 1.ToString ();
using (var mc = new MemoryCache ("TestCacheExpiryOrdering", config)) {
Assert.AreEqual (0, mc.GetCount (), "#CEO1");
@@ -1349,6 +1337,9 @@ namespace MonoTests.System.Runtime.Caching
global::System.Threading.Thread.Sleep (4 * 1000);
for (int i = 0; i < 100; i++) {
Assert.IsNull (mc.Get ("short-" + i), "#CEO4-" + i);
}
Assert.AreEqual (100, mc.GetCount (), "#CEO4");
}
}
@@ -1359,11 +1350,7 @@ namespace MonoTests.System.Runtime.Caching
var config = new NameValueCollection ();
config["cacheMemoryLimitMegabytes"] = 0.ToString ();
config["physicalMemoryLimitPercentage"] = 100.ToString ();
config["__MonoEmulateOneCPU"] = true.ToString ();
// it appears that pollingInterval does nothing, so we set the Mono timer as well
config["pollingInterval"] = new TimeSpan (0, 0, 1).ToString ();
config["__MonoTimerPeriod"] = 1.ToString ();
using (var mc = new MemoryCache ("TestCacheSliding", config)) {
Assert.AreEqual (0, mc.GetCount (), "#CSL1");
@@ -1390,10 +1377,16 @@ namespace MonoTests.System.Runtime.Caching
Assert.AreNotEqual (null, item, "#CSL3-" + i);
}
Assert.IsNull (mc.Get ("expire1"), "#CSL4-1");
Assert.IsNull (mc.Get ("expire2"), "#CSL4-2");
Assert.IsNull (mc.Get ("expire3"), "#CSL4-3");
Assert.IsNull (mc.Get ("expire4"), "#CSL4-4");
Assert.IsNull (mc.Get ("expire5"), "#CSL4-5");
Assert.AreEqual (1, mc.GetCount (), "#CSL4");
global::System.Threading.Thread.Sleep (4 * 1000);
Assert.IsNull (mc.Get ("slidingtest"), "#CSL5a");
Assert.AreEqual (0, mc.GetCount (), "#CSL5");
}
}