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 shutdown
0.7.4.1
Justin Clark-Casey (justincc) 2012-05-11 01:37:03 +01:00
parent dc39ec82fa
commit 93b615c51d
1 changed files with 13 additions and 8 deletions

View File

@ -251,13 +251,21 @@ namespace pCampBot
}
/// <summary>
/// Shutting down all bots
/// Shut down all bots
/// </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()
{
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>
@ -271,11 +279,8 @@ namespace pCampBot
private void HandleShutdown(string module, string[] cmd)
{
Util.FireAndForget(o =>
{
m_log.Warn("[BOTMANAGER]: Shutting down bots");
doBotShutdown();
});
m_log.Info("[BOTMANAGER]: Shutting down bots");
doBotShutdown();
}
private void HandleShowRegions(string module, string[] cmd)