v0.2.2: updated Lidgren, railgun shells can be bought, autorestart server, netstats, tutorial moloch spawning in a wall fix, misc error checks
This commit is contained in:
@@ -22,6 +22,10 @@ using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
//
|
||||
// Comment for Linux Mono users: reports of library thread hangs on EnterReadLock() suggests switching to plain lock() works better
|
||||
//
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
/// <summary>
|
||||
@@ -52,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
|
||||
@@ -193,6 +214,15 @@ namespace Lidgren.Network
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
#if DEBUG
|
||||
throw;
|
||||
#else
|
||||
item = default(T);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_lock.ExitWriteLock();
|
||||
@@ -200,7 +230,7 @@ namespace Lidgren.Network
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an item from the head of the queue, or returns default(T) if empty
|
||||
/// Gets all items from the head of the queue, or returns number of items popped
|
||||
/// </summary>
|
||||
public int TryDrain(IList<T> addTo)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user