private void DispatchQueryThreadActions()
{
IALFADatabase Database = DatabaseLinkQueryThread;
QueryThreadAction Action = null;
uint StartTick = (uint)Environment.TickCount;
//
// Loop dispatching query thread actions. Query thread actions are
// executed in-order and on the query thread, with a reference to a
// database object to perform potentially long-running queries.
//
// The world manager is NOT locked for the duration of the
// execution request, and the action queue is also NOT locked for
// the duration of the execution request.
//
for (; ; )
{
lock (QueryThreadActionQueue)
{
if (QueryThreadActionQueue.Count == 0)
break;
Action = QueryThreadActionQueue.Dequeue();
}
Action(Database);
//
// If we have spent more than the alotted time this cycle in
// processing generic actions, break out of the loop so that
// other tasks (such as cross-server communication) have a
// chance to run.
//
if ((uint)Environment.TickCount - StartTick >= QUERY_THREAD_ACTION_QUOTA)
break;
}
}