1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-14 14:16:30 +09:00

Fix data race in Capacity/Count of NetQueue.

This commit is contained in:
Marius Ungureanu
2015-09-05 10:48:39 +03:00
parent afbe41bb6d
commit 0f9ca1d106

View File

@@ -56,12 +56,29 @@ namespace Lidgren.Network
/// <summary>
/// Gets the number of items in the queue
/// </summary>
public int Count { get { return m_size; } }
public int Count {
get
{
m_lock.EnterReadLock();
int count = m_size;
m_lock.ExitReadLock();
return count;
}
}
/// <summary>
/// Gets the current capacity for the queue
/// </summary>
public int Capacity { get { return m_items.Length; } }
public int Capacity
{
get
{
m_lock.EnterReadLock();
int capacity = m_items.Length;
m_lock.ExitReadLock();
return capacity;
}
}
/// <summary>
/// NetQueue constructor