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

Enumerated and exposed network thread name

This commit is contained in:
lidgren
2010-08-13 06:44:07 +00:00
parent 38bb13b3a7
commit cf60a5ef57
3 changed files with 31 additions and 24 deletions

View File

@@ -31,6 +31,8 @@ namespace Lidgren.Network
[DebuggerDisplay("Status={m_status}")]
public partial class NetPeer
{
private static int s_threadCount = 0;
internal const int kMinPacketHeaderSize = 2;
internal const int kMaxPacketHeaderSize = 5;
@@ -51,6 +53,11 @@ namespace Lidgren.Network
/// </summary>
public NetPeerStatus Status { get { return m_status; } }
/// <summary>
/// Name of the network thread (if NetPeer.Start has been called)
/// </summary>
public string NetworkThreadName { get { return (m_networkThread == null ? string.Empty : m_networkThread.Name); } }
/// <summary>
/// Gets a copy of the list of connections
/// </summary>
@@ -141,10 +148,10 @@ namespace Lidgren.Network
m_configuration.VerifyAndLock();
InitializeNetwork();
// start network thread
m_networkThread = new Thread(new ThreadStart(NetworkLoop));
m_networkThread.Name = "Lidgren network thread";
m_networkThread.Name = "Lidgren network thread " + Interlocked.Increment(ref s_threadCount).ToString();
m_networkThread.IsBackground = true;
m_networkThread.Start();

View File

@@ -53,7 +53,7 @@ namespace Lidgren.Network
private const double c_realUnitUint = 1.0 / ((double)uint.MaxValue + 1.0);
private const uint c_y = 842502087, c_z = 3579807591, c_w = 273326509;
private static int m_extraSeed = 42;
private static int s_extraSeed = 42;
uint m_x, m_y, m_z, m_w;
@@ -68,7 +68,7 @@ namespace Lidgren.Network
seed ^= (int)(Stopwatch.GetTimestamp());
seed ^= (int)(Environment.WorkingSet); // will return 0 on mono
int extraSeed = Interlocked.Increment(ref m_extraSeed);
int extraSeed = Interlocked.Increment(ref s_extraSeed);
return seed + extraSeed;
}