Ejemplo n.º 1
0
        public static void ThreadWork(object arg)
        {
            int            tid       = (int)arg;
            AiWorkerThread my_thread = threads[tid];

            while (running)
            {
                my_thread.threadLock.WaitOne();
                AiBrain current_brain = null;
                if (my_thread.NumBrains > 0)
                {
                    current_brain = my_thread.readyQueue[0];
                    my_thread.readyQueue.RemoveAt(0);
                    my_thread.readyQueue.Add(current_brain);
                }
                my_thread.threadLock.ReleaseMutex();
                if (current_brain != null)
                {
                    Console.WriteLine("Processing Brain");
                    current_brain.Process();
                }
            }
            Console.WriteLine("Exiting {0}", tid);
        }
Ejemplo n.º 2
0
 public static void RemoveBrain(AiBrain brain)
 {
     AddListMutex.WaitOne();
     remove_list.Add(brain);
     AddListMutex.ReleaseMutex();
 }
Ejemplo n.º 3
0
 public static bool HasBrain(AiBrain b)
 {
     return(BrainMapping.ContainsKey(b));
 }
Ejemplo n.º 4
0
 public static void AddBrain(AiBrain brain)
 {
     AddListMutex.WaitOne();
     add_list.Add(brain);
     AddListMutex.ReleaseMutex();
 }