public WhiteCoreThreadPool(WhiteCoreThreadPoolStartInfo 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
 }
Exemplo n.º 2
0
        public virtual void RegionLoaded (IScene scene)
        {
            if (!m_Enabled)
                return;

            WhiteCoreThreadPoolStartInfo info = new WhiteCoreThreadPoolStartInfo { priority = ThreadPriority.Lowest, Threads = 1 };
            threadpool = new WhiteCoreThreadPool (info);
            blockthreadpool = new WhiteCoreThreadPool (info);
        }
        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
            WhiteCoreThreadPoolStartInfo info = new WhiteCoreThreadPoolStartInfo
                                                 {
                                                     priority = ThreadPriority.Normal,
                                                     Threads = 1,
                                                     MaxSleepTime = Engine.Config.GetInt("SleepTime", 100),
                                                     SleepIncrementTime = Engine.Config.GetInt("SleepIncrementTime", 1),
                                                     Name = "Script Cmd Thread Pools"
                                                 };
            cmdThreadpool = new WhiteCoreThreadPool(info);
            
            WhiteCoreThreadPoolStartInfo scinfo = new WhiteCoreThreadPoolStartInfo
                                                 {
                                                     priority = ThreadPriority.Normal,
                                                     Threads = 1,
                                                     MaxSleepTime = Engine.Config.GetInt("SleepTime", 100),
                                                     SleepIncrementTime = Engine.Config.GetInt("SleepIncrementTime", 1),
                                                     Name = "Script Loading Thread Pools"
                                                 };
        
            scriptChangeThreadpool = new WhiteCoreThreadPool(scinfo);

            MaxScriptThreads = Engine.Config.GetInt("MaxScriptThreads", 100); // leave control threads out of user option
            WhiteCoreThreadPoolStartInfo sinfo = new WhiteCoreThreadPoolStartInfo
                                                  {
                                                      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 WhiteCoreThreadPool(sinfo);

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