mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 02:05:34 +08:00
In the pursuit of using less CPU: now trying to avoid blocking queues altogether. Instead, this uses a timer. No sure if it's better or worse, but worth the try.
This commit is contained in:
@@ -61,8 +61,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
||||
|
||||
// Throttle the name requests
|
||||
//private OpenSim.Framework.BlockingQueue<NameRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<NameRequest>();
|
||||
private OpenSim.Framework.DoubleQueue<NameRequest> m_RequestQueue = new OpenSim.Framework.DoubleQueue<NameRequest>();
|
||||
//private OpenSim.Framework.DoubleQueue<NameRequest> m_RequestQueue = new OpenSim.Framework.DoubleQueue<NameRequest>();
|
||||
private Queue<NameRequest> m_RequestQueue = new Queue<NameRequest>();
|
||||
|
||||
private System.Timers.Timer m_timer;
|
||||
|
||||
#region ISharedRegionModule
|
||||
|
||||
@@ -599,12 +601,18 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
||||
protected void Init()
|
||||
{
|
||||
RegisterConsoleCmds();
|
||||
Watchdog.StartThread(
|
||||
ProcessQueue,
|
||||
"NameRequestThread",
|
||||
ThreadPriority.BelowNormal,
|
||||
true,
|
||||
false);
|
||||
//Watchdog.StartThread(
|
||||
// ProcessQueue,
|
||||
// "NameRequestThread",
|
||||
// ThreadPriority.BelowNormal,
|
||||
// true,
|
||||
// false);
|
||||
|
||||
m_timer = new System.Timers.Timer();
|
||||
m_timer.AutoReset = false;
|
||||
m_timer.Interval = 15000; // 15 secs at first
|
||||
m_timer.Elapsed += ProcessQueue;
|
||||
m_timer.Start();
|
||||
|
||||
}
|
||||
|
||||
@@ -698,6 +706,48 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
||||
}
|
||||
}
|
||||
|
||||
private bool AreThereRootAgents()
|
||||
{
|
||||
foreach (Scene s in m_Scenes)
|
||||
{
|
||||
if (s.GetRootAgentCount() > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ProcessQueue(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
while (m_RequestQueue.Count > 0)
|
||||
{
|
||||
NameRequest request = null;
|
||||
lock (m_RequestQueue)
|
||||
request = m_RequestQueue.Dequeue();
|
||||
|
||||
if (request != null)
|
||||
{
|
||||
string[] names;
|
||||
bool foundRealName = TryGetUserNames(request.uuid, out names);
|
||||
|
||||
if (names.Length == 2)
|
||||
{
|
||||
if (!foundRealName)
|
||||
m_log.DebugFormat("[USER MANAGEMENT MODULE]: Sending {0} {1} for {2} to {3} since no bound name found", names[0], names[1], request.uuid, request.client.Name);
|
||||
|
||||
request.client.SendNameReply(request.uuid, names[0], names[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (AreThereRootAgents())
|
||||
m_timer.Interval = 1000; // 1 sec
|
||||
else
|
||||
m_timer.Interval = 10000; // 10 secs
|
||||
|
||||
m_timer.Start();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class NameRequest
|
||||
|
||||
Reference in New Issue
Block a user