Пример #1
0
        public static void Setup()
        {
            if (hasSetup)
            {
                return;
            }
            hasSetup = true;

            int maxThreadCount = Math.Min(BismuthConfig.GetConfigValue <int>("ThreadPool.MaxThreads", DEFAULT_THREAD_COUNT), MAX_THREADS);

            if (maxThreadCount <= 0)
            {
                LogManager.Warn("ThreadPool", "Invalid thread pool count '" + maxThreadCount + "', defaulting to " + DEFAULT_THREAD_COUNT + " threads");
                maxThreadCount = DEFAULT_THREAD_COUNT;
            }

            LogManager.Log("ThreadPool", "Starting thread pool with " + maxThreadCount + " threads");

            for (int i = 0; i < maxThreadCount; ++i)
            {
                Thread worker = new Thread(WorkerFunction)
                {
                    Name = "BismuthThread" + i.ToString().PadLeft(5, '0')
                };
                worker.Start();
                WorkerThreads.AddLast(worker);
            }

            LogManager.Log("ThreadPool", "Thread pool started");
        }
Пример #2
0
        static void RunBismuth(string[] args)
        {
            //Load plugins
            if (!BismuthConfig.Setup())
            {
                return;
            }

            BismuthThreadPool.Setup();
            SetupManagersFromLoadedAssemblies();

            ModeFlagBindings.AddBindings("HELP", "Displays this help text", new string[] { "h", "help" });
            RCONServer.AddRCONCommand("version", "Lists the Bismuth version information", (a) => { return(Program.GetFullProgramVersionString()); });
            RCONServer.AddRCONCommand("status", "Lists various statistics about the current Bismuth process", (a) => { return(GetStatus(true)); });
            RCONServer.AddRCONCommand("list-managers", "Lists all currently running managers", (a) => { return(ListManagers(true)); });

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i][0] == '-')
                {
                    if (args[i][1] == '-')
                    {
                        ModeFlagBindings.SetFlag(args[i].Substring(2));
                    }
                    else
                    {
                        for (int j = 1; j < args[i].Length; j++)
                        {
                            ModeFlagBindings.SetFlag(args[i][j]);
                        }
                    }
                }
            }

            if (ModeFlagBindings.IsFlagSet("HELP"))
            {
                ModeFlagBindings.PrintHelp();
                return;
            }

            LogManager.Log("Main Thread", "Beginning primary execution loop");
            while (!ShutDown)
            {
                //TODO: Handle plugin receive handler
                NetworkManager.ListenForNewConnections();
                Thread.Sleep(1);
            }
            LogManager.Log("Main Thread", "Primary execution loop quit");
        }