Do each bot shutdown on its own threads to prevent one slow shutdown holding up all the rest.
This does increase the aggressiveness of shutdown Also prevents the bot list being locked for a long period, which was preventing commands such as "show bots" from working during shutdown0.7.4.1
parent
dc39ec82fa
commit
93b615c51d
|
@ -251,13 +251,21 @@ namespace pCampBot
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shutting down all bots
|
/// Shut down all bots
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// We launch each shutdown on its own thread so that a slow shutting down bot doesn't hold up all the others.
|
||||||
|
/// </remarks>
|
||||||
public void doBotShutdown()
|
public void doBotShutdown()
|
||||||
{
|
{
|
||||||
lock (m_lBot)
|
lock (m_lBot)
|
||||||
foreach (Bot pb in m_lBot)
|
{
|
||||||
pb.shutdown();
|
foreach (Bot bot in m_lBot)
|
||||||
|
{
|
||||||
|
Bot thisBot = bot;
|
||||||
|
Util.FireAndForget(o => thisBot.shutdown());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -271,11 +279,8 @@ namespace pCampBot
|
||||||
|
|
||||||
private void HandleShutdown(string module, string[] cmd)
|
private void HandleShutdown(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
Util.FireAndForget(o =>
|
m_log.Info("[BOTMANAGER]: Shutting down bots");
|
||||||
{
|
|
||||||
m_log.Warn("[BOTMANAGER]: Shutting down bots");
|
|
||||||
doBotShutdown();
|
doBotShutdown();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleShowRegions(string module, string[] cmd)
|
private void HandleShowRegions(string module, string[] cmd)
|
||||||
|
|
Loading…
Reference in New Issue