You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@ -0,0 +1,56 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
namespace System.ServiceModel
|
||||
{
|
||||
// see SynchronizedPool<T> for a threadsafe implementation
|
||||
class Pool<T> where T : class
|
||||
{
|
||||
T[] items;
|
||||
int count;
|
||||
|
||||
public Pool(int maxCount)
|
||||
{
|
||||
items = new T[maxCount];
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return count; }
|
||||
}
|
||||
|
||||
public T Take()
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
T item = items[--count];
|
||||
items[count] = null;
|
||||
return item;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Return(T item)
|
||||
{
|
||||
if (count < items.Length)
|
||||
{
|
||||
items[count++] = item;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
items[i] = null;
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user