+ Execute and store the results of the Linq query as a List to prevent collection modified exceptions.

* The List is a member of PooledEnumerable<T> and is thus pooled along with it.
This commit is contained in:
Vorspire 2015-08-23 02:13:49 +01:00
parent af86aa23c7
commit a32c4573ad

View file

@ -1743,7 +1743,7 @@ namespace Server
if (e != null)
{
e._Pool = pool;
e._Pool.AddRange(pool);
}
else
{
@ -1754,11 +1754,11 @@ namespace Server
}
private bool _IsDisposed;
private IEnumerable<T> _Pool;
private List<T> _Pool;
public PooledEnumerable(IEnumerable<T> pool)
{
_Pool = pool;
_Pool = new List<T>(pool);
}
IEnumerator IEnumerable.GetEnumerator()
@ -1778,7 +1778,7 @@ namespace Server
return;
}
_Pool = null;
_Pool.Clear();
lock (((ICollection)_Buffer).SyncRoot)
{
@ -1789,6 +1789,9 @@ namespace Server
public void Dispose()
{
_IsDisposed = true;
_Pool.Clear();
_Pool.TrimExcess();
_Pool = null;
}
}