You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-18 16:16:35 +09:00
Fix data race in Capacity/Count of NetQueue.
This commit is contained in:
@@ -56,12 +56,29 @@ namespace Lidgren.Network
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the number of items in the queue
|
/// Gets the number of items in the queue
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// Gets the current capacity for the queue
|
/// Gets the current capacity for the queue
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// NetQueue constructor
|
/// NetQueue constructor
|
||||||
|
|||||||
Reference in New Issue
Block a user