Merge branch 'master' into texture-dispose-fix

This commit is contained in:
Dan Balasescu 2018-09-13 11:54:23 +09:00 committed by GitHub
commit 96b4cb7821
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions

View File

@ -59,7 +59,7 @@ public abstract class ArchiveModelManager<TModel, TFileModel> : ICanAcceptFiles
// ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
private ArchiveImportIPCChannel ipc;
private readonly List<Action> cachedEvents = new List<Action>();
private readonly List<Action> queuedEvents = new List<Action>();
/// <summary>
/// Allows delaying of outwards events until an operation is confirmed (at a database level).
@ -77,20 +77,26 @@ public abstract class ArchiveModelManager<TModel, TFileModel> : ICanAcceptFiles
/// <param name="perform">Whether the flushed events should be performed.</param>
private void flushEvents(bool perform)
{
Action[] events;
lock (queuedEvents)
{
events = queuedEvents.ToArray();
queuedEvents.Clear();
}
if (perform)
{
foreach (var a in cachedEvents)
foreach (var a in events)
a.Invoke();
}
cachedEvents.Clear();
delayingEvents = false;
}
private void handleEvent(Action a)
{
if (delayingEvents)
cachedEvents.Add(a);
lock (queuedEvents) queuedEvents.Add(a);
else
a.Invoke();
}

View File

@ -54,7 +54,7 @@ private void load(RulesetStore rulesets)
AddStep(r.Name, () => p = loadPlayerFor(r));
AddUntilStep(() => ContinueCondition(p));
AddAssert("no leaked beatmaps", () =>
AddUntilStep(() =>
{
p = null;
@ -64,9 +64,9 @@ private void load(RulesetStore rulesets)
workingWeakReferences.ForEachAlive(_ => count++);
return count == 1;
});
}, "no leaked beatmaps");
AddAssert("no leaked players", () =>
AddUntilStep(() =>
{
GC.Collect();
GC.WaitForPendingFinalizers();
@ -74,7 +74,7 @@ private void load(RulesetStore rulesets)
playerWeakReferences.ForEachAlive(_ => count++);
return count == 1;
});
}, "no leaked players");
}
}
}