Exemplo n.º 1
0
 public UniverseThreadPool(UniverseThreadPoolStartInfo info)
 {
     m_info           = info;
     Threads          = new Thread[m_info.Threads];
     Sleeping         = new int[m_info.Threads];
     nthreads         = 0;
     nSleepingthreads = 0;
     // lets threads check for work a bit faster in case we have all sleeping and awake interrupt fails
 }
 public UniverseThreadPool(UniverseThreadPoolStartInfo info)
 {
     m_info = info;
     Threads = new Thread[m_info.Threads];
     Sleeping = new int[m_info.Threads];
     nthreads = 0;
     nSleepingthreads = 0;
     // lets threads check for work a bit faster in case we have all sleeping and awake interrupt fails
 }
        public virtual void RegionLoaded(IScene scene)
        {
            if (!m_Enabled)
                return;

            UniverseThreadPoolStartInfo info = new UniverseThreadPoolStartInfo
                                                 {priority = ThreadPriority.Lowest, Threads = 1};
            threadpool = new UniverseThreadPool(info);
            blockthreadpool = new UniverseThreadPool(info);
        }
Exemplo n.º 4
0
        public MaintenanceThread(ScriptEngine Engine)
        {
            m_ScriptEngine = Engine;
            EventManager = Engine.EventManager;

            RunInMainProcessingThread = Engine.Config.GetBoolean("RunInMainProcessingThread", false);

            RunInMainProcessingThread = false; // temporary false until code is fix to work with true

            //There IS a reason we start this, even if RunInMain is enabled
            // If this isn't enabled, we run into issues with the CmdHandlerQueue,
            // as it always must be async, so we must run the pool anyway
            UniverseThreadPoolStartInfo info = new UniverseThreadPoolStartInfo
                                                 {
                                                     priority = ThreadPriority.Normal,
                                                     Threads = 1,
                                                     MaxSleepTime = Engine.Config.GetInt("SleepTime", 100),
                                                     SleepIncrementTime = Engine.Config.GetInt("SleepIncrementTime", 1),
                                                     Name = "Script Cmd Thread Pools"
                                                 };
            cmdThreadpool = new UniverseThreadPool(info);

            UniverseThreadPoolStartInfo scinfo = new UniverseThreadPoolStartInfo
                                                 {
                                                     priority = ThreadPriority.Normal,
                                                     Threads = 1,
                                                     MaxSleepTime = Engine.Config.GetInt("SleepTime", 100),
                                                     SleepIncrementTime = Engine.Config.GetInt("SleepIncrementTime", 1),
                                                     Name = "Script Loading Thread Pools"
                                                 };

            scriptChangeThreadpool = new UniverseThreadPool(scinfo);

            MaxScriptThreads = Engine.Config.GetInt("MaxScriptThreads", 100); // leave control threads out of user option
            UniverseThreadPoolStartInfo sinfo = new UniverseThreadPoolStartInfo
                                                  {
                                                      priority = ThreadPriority.Normal,
                                                      Threads = MaxScriptThreads,
                                                      MaxSleepTime = Engine.Config.GetInt("SleepTime", 100),
                                                      SleepIncrementTime = Engine.Config.GetInt("SleepIncrementTime", 1),
                                                      KillThreadAfterQueueClear = true,
                                                      Name = "Script Event Thread Pools"
                                                  };
            scriptThreadpool = new UniverseThreadPool(sinfo);

            AppDomain.CurrentDomain.AssemblyResolve += m_ScriptEngine.AssemblyResolver.OnAssemblyResolve;
        }