You've already forked lidgren-network-gen3
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user