public BaseOpenSimServer() { m_startuptime = DateTime.Now; // Random uuid for private data m_osSecret = UUID.Random().ToString(); m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); m_periodicDiagnosticsTimer.Enabled = true; // Add ourselves to thread monitoring. This thread will go on to become the console listening thread Thread.CurrentThread.Name = "ConsoleThread"; ThreadTracker.Add(Thread.CurrentThread); ILoggerRepository repository = LogManager.GetRepository(); IAppender[] appenders = repository.GetAppenders(); foreach (IAppender appender in appenders) { if (appender.Name == "LogFileAppender") { m_logFileAppender = appender; } } System.Console.CancelKeyPress += new System.ConsoleCancelEventHandler(HandleConsoleCancelEvent); }
public void Init(object gameInstance) { var assembly = Assembly.GetExecutingAssembly(); var version = assembly.GetName().Version; // Set up resources that persist outside of sessions ThreadTracker.SetGameThread(); Log.Log("Loading Plugin for SEPC version " + version); try { // Register our compilation symbol state SymbolRegistrar.SetDebugIfDefined(); SymbolRegistrar.SetProfileIfDefined(); // Register our SEPC-managed SessionComponents ComponentRegistrar.AddComponents(assembly); ComponentRegistrar.LoadOnInit(0, assembly); } catch (Exception error) { Log.Error(error); } }
public void Start() { _engine = new Thread(new ThreadStart(Engine)); _engine.IsBackground = true; _engine.Start(); _engine.Name = string.Format("Engine:{0}", EngineID); ThreadTracker.Add(_engine); }
public void Start() { _engine = new Thread(new ThreadStart(Engine)); _engine.Name = EngineID; _engine.IsBackground = true; _engine.Start(); ThreadTracker.Add(_engine); }
public virtual void Start() { m_log.Debug("[ASSET SERVER]: Starting asset server"); m_localAssetServerThread = new Thread(RunRequests); m_localAssetServerThread.Name = "LocalAssetServerThread"; m_localAssetServerThread.IsBackground = true; m_localAssetServerThread.Start(); ThreadTracker.Add(m_localAssetServerThread); }
public void Process() { httpThread = new Thread(SendRequest); httpThread.Name = "HttpRequestThread"; httpThread.Priority = ThreadPriority.BelowNormal; httpThread.IsBackground = true; _finished = false; httpThread.Start(); ThreadTracker.Add(httpThread); }
/// <summary> /// Starts maintenance thread /// </summary> private void StartMaintenanceThread() { if (MaintenanceThreadThread == null) { MaintenanceThreadThread = new Thread(MaintenanceLoop); MaintenanceThreadThread.Name = "ScriptMaintenanceThread"; MaintenanceThreadThread.IsBackground = true; MaintenanceThreadThread.Start(); ThreadTracker.Add(MaintenanceThreadThread); } }
public void run(object o) { for (int i = 0; i < arrassets.Length; i++) { AssetBase ab = sn.AssetService.Get(arrassets[i].ToString()); if (ab != null && ab.Data != null) { j2kdecode.syncdecode(arrassets[i], ab.Data); } } ThreadTracker.Remove(thisthread); }
public void run(object o) { for (int i = 0; i < arrassets.Length; i++) { AssetBase ab = sn.CommsManager.AssetCache.GetAsset(arrassets[i], AssetRequestInfo.InternalRequest()); if (ab != null && ab.Data != null) { j2kdecode.Decode(arrassets[i], ab.Data); } } ThreadTracker.Remove(thisthread); }
public OSHttpRequestPump(OSHttpServer server, OSHttpRequestQueue queue, int id) { _server = server; _queue = queue; _id = id; _engine = new Thread(new ThreadStart(Engine)); _engine.Name = EngineID; _engine.IsBackground = true; _engine.Start(); ThreadTracker.Add(_engine); }
private void Initialize(CMModel model, CMView view, Scene scene, int channel) { lock (this) { m_estateModule = scene.RequestModuleInterface <IEstateModule>(); m_thread = new Thread(MainLoop); m_thread.Name = "Content Management"; m_thread.IsBackground = true; m_thread.Start(); ThreadTracker.Add(m_thread); m_state = State.NONE; } }
private static void StartThread() { if (cmdHandlerThread == null) { // Start the thread that will be doing the work cmdHandlerThread = new Thread(CmdHandlerThreadLoop); cmdHandlerThread.Name = "AsyncLSLCmdHandlerThread"; //cmdHandlerThread.Priority = ThreadPriority.BelowNormal; cmdHandlerThread.IsBackground = true; cmdHandlerThread.Start(); ThreadTracker.Add(cmdHandlerThread); } }
/// <summary> /// Start the HTTP server engine. /// </summary> public void Start() { _engine = new Thread(new ThreadStart(Engine)); _engine.IsBackground = true; _engine.Start(); _engine.Name = string.Format("Engine:{0}", _engineId); ThreadTracker.Add(_engine); // start the pumps... for (int i = 0; i < _pumps.Length; i++) { _pumps[i].Start(); } }
/// <summary> /// Starts the MapItemRequest Thread /// Note that this only gets started when there are actually agents in the region /// Additionally, it gets stopped when there are none. /// </summary> /// <param name="o"></param> private void StartThread(object o) { if (threadrunning) { return; } threadrunning = true; m_log.Debug("[WORLD MAP]: Starting remote MapItem request thread"); mapItemReqThread = new Thread(new ThreadStart(process)); mapItemReqThread.IsBackground = true; mapItemReqThread.Name = "MapItemRequestThread"; mapItemReqThread.Priority = ThreadPriority.BelowNormal; mapItemReqThread.SetApartmentState(ApartmentState.MTA); mapItemReqThread.Start(); ThreadTracker.Add(mapItemReqThread); }
public MXPPacketServer(int port, Dictionary <UUID, Scene> scenes, bool accountsAuthenticate) { m_port = port; m_accountsAuthenticate = accountsAuthenticate; m_scenes = scenes; m_programMinorVersion = 63; m_programMajorVersion = 0; m_programName = "OpenSimulator"; m_transmitter = new Transmitter(port); m_clientThread = new Thread(StartListener); m_clientThread.Name = "MXPThread"; m_clientThread.IsBackground = true; m_clientThread.Start(); ThreadTracker.Add(m_clientThread); }
/// <summary> /// Start thread /// </summary> private void Start() { EventQueueThread = new Thread(EventQueueThreadLoop); EventQueueThread.IsBackground = true; EventQueueThread.Priority = MyThreadPriority; EventQueueThread.Name = "EventQueueManagerThread_" + ThreadCount; EventQueueThread.Start(); ThreadTracker.Add(EventQueueThread); // Look at this... Don't you wish everyone did that solid // coding everywhere? :P if (ThreadCount == int.MaxValue) { ThreadCount = 0; } ThreadCount++; }
public void Initialize(Scene scene, IConfigSource config) { if (m_scene == null) { //m_log.Debug("Creating Texture download module"); m_scene = scene; m_thread = new Thread(new ThreadStart(ProcessTextureSenders)); m_thread.Name = "ProcessTextureSenderThread"; m_thread.IsBackground = true; m_thread.Start(); ThreadTracker.Add(m_thread); } if (!m_scenes.Contains(scene)) { m_scenes.Add(scene); m_scene = scene; m_scene.EventManager.OnNewClient += NewClient; m_scene.EventManager.OnRemovePresence += EventManager_OnRemovePresence; } }
private static void Unload() { if (value_static == null) { return; } Static.m_lockLogging.AcquireExclusive(); try { LogItem closingLog = new LogItem() { //context = null, fileName = typeof(Logger).ToString(), time = DateTime.Now, level = severity.INFO, //member = null, //lineNumber = 0, toLog = "Closing log", //primaryState = null, //secondaryState = null, thread = ThreadTracker.GetNameOrNumber() }; log(ref closingLog); if (Static.logWriter != null) { Static.logWriter.Flush(); Static.logWriter.Close(); Static.logWriter = null; } } catch (ObjectDisposedException) { } finally { Static.m_lockLogging.ReleaseExclusive(); value_static = null; } }
public void BaseSafetyQuueTest() { Console.WriteLine("233333"); for (int i = 0; i < Number; i++) { threads[i].Start(); } //.Sleep(100); for (int i = 0; i < 80020; i++) { A0 a; if (queue.Dequeue(out a)) { //Console.WriteLine(i + ":"+a.id); } else { //Console.WriteLine(i + ":null"); } } ThreadTracker.OutPut(); }
/// <summary> /// This starts up the bot and stores the thread for the bot in the thread array /// </summary> /// <param name="pos">The position in the thread array to stick the bot's thread</param> /// <param name="cs">Configuration of the bot</param> public void startupBot(int pos, IConfig cs) { PhysicsBot pb = new PhysicsBot(cs); pb.OnConnected += handlebotEvent; pb.OnDisconnected += handlebotEvent; if (cs.GetString("firstname", "random") == "random") { pb.firstname = CreateRandomName(); } if (cs.GetString("lastname", "random") == "random") { pb.lastname = CreateRandomName(); } m_td[pos] = new Thread(pb.startup); m_td[pos].Name = "CampBot_" + pos; m_td[pos].IsBackground = true; m_td[pos].Start(); m_lBot.Add(pb); ThreadTracker.Add(m_td[pos]); }
/// <summary> /// Processing thread main() loop for doing remote mapitem requests /// </summary> public void process() { try { while (true) { MapRequestState st = requests.Dequeue(); // end gracefully if (st.agentID == UUID.Zero) { ThreadTracker.Remove(mapItemReqThread); break; } bool dorequest = true; lock (m_rootAgents) { if (!m_rootAgents.Contains(st.agentID)) { dorequest = false; } } if (dorequest) { OSDMap response = RequestMapItemsAsync("", st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); RequestMapItemsCompleted(response); } } } catch (Exception e) { m_log.ErrorFormat("[WORLD MAP]: Map item request thread terminated abnormally with exception {0}", e); } threadrunning = false; }
/// <summary> /// Get a report about the registered threads in this server. /// </summary> protected string GetThreadsReport() { StringBuilder sb = new StringBuilder(); List <Thread> threads = ThreadTracker.GetThreads(); if (threads == null) { sb.Append("Thread tracking is only enabled in DEBUG mode."); } else { sb.Append(threads.Count + " threads are being tracked:" + Environment.NewLine); foreach (Thread t in threads) { if (t.IsAlive) { sb.Append( "ID: " + t.ManagedThreadId + ", Name: " + t.Name + ", Alive: " + t.IsAlive + ", Pri: " + t.Priority + ", State: " + t.ThreadState + Environment.NewLine); } else { try { sb.Append("ID: " + t.ManagedThreadId + ", Name: " + t.Name + ", DEAD" + Environment.NewLine); } catch { sb.Append("THREAD ERROR" + Environment.NewLine); } } } } return(sb.ToString()); }
/// <summary> /// Get a report about the registered threads in this server. /// </summary> protected string GetThreadsReport() { StringBuilder sb = new StringBuilder(); ProcessThreadCollection threads = ThreadTracker.GetThreads(); if (threads == null) { sb.Append("OpenSim thread tracking is only enabled in DEBUG mode."); } else { sb.Append(threads.Count + " threads are being tracked:" + Environment.NewLine); foreach (ProcessThread t in threads) { sb.Append("ID: " + t.Id + ", TotalProcessorTime: " + t.TotalProcessorTime + ", TimeRunning: " + (DateTime.Now - t.StartTime) + ", Pri: " + t.CurrentPriority + ", State: " + t.ThreadState); if (t.ThreadState == System.Diagnostics.ThreadState.Wait) { sb.Append(", Reason: " + t.WaitReason + Environment.NewLine); } else { sb.Append(Environment.NewLine); } } } int workers = 0, ports = 0, maxWorkers = 0, maxPorts = 0; ThreadPool.GetAvailableThreads(out workers, out ports); ThreadPool.GetMaxThreads(out maxWorkers, out maxPorts); sb.Append(Environment.NewLine + "*** ThreadPool threads ***" + Environment.NewLine); sb.Append("workers: " + (maxWorkers - workers) + " (" + maxWorkers + "); ports: " + (maxPorts - ports) + " (" + maxPorts + ")" + Environment.NewLine); return(sb.ToString()); }
private static void log(string context, string fileName, severity level, string member, int lineNumber, string toLog, string primaryState = null, string secondaryState = null) { if (Globals.WorldClosed) { return; } if (Static.numLines >= Static.maxNumLines) { return; } if (level <= severity.WARNING) { DebugNotify("Logger: " + level, 2000, level); } Static.m_logItems.AddTail(new LogItem() { context = context, fileName = fileName, time = DateTime.Now, level = level, member = member, lineNumber = lineNumber, toLog = toLog, primaryState = primaryState, secondaryState = secondaryState, thread = ThreadTracker.GetNameOrNumber() }); if (MyAPIGateway.Parallel != null) { MyAPIGateway.Parallel.StartBackground(logLoop); } }
public UpdateManager() { ThreadTracker.SetGameThread(); Instance = this; MainLock.MainThread_AcquireExclusive(); }
public void CacheJ2kDecode(int threads) { if (threads < 1) { threads = 1; } IJ2KDecoder m_decoder = m_localScenes[0].RequestModuleInterface <IJ2KDecoder>(); List <UUID> assetRequestList = new List <UUID>(); #region AssetGathering! foreach (Scene scene in m_localScenes) { List <EntityBase> entitles = scene.GetEntities(); foreach (EntityBase entity in entitles) { if (entity is SceneObjectGroup) { SceneObjectGroup sog = (SceneObjectGroup)entity; foreach (SceneObjectPart part in sog.Children.Values) { if (part.Shape != null) { OpenMetaverse.Primitive.TextureEntry te = part.Shape.Textures; if (te.DefaultTexture != null) // this has been null for some reason... { if (te.DefaultTexture.TextureID != UUID.Zero) { assetRequestList.Add(te.DefaultTexture.TextureID); } } for (int i = 0; i < te.FaceTextures.Length; i++) { if (te.FaceTextures[i] != null) { if (te.FaceTextures[i].TextureID != UUID.Zero) { assetRequestList.Add(te.FaceTextures[i].TextureID); } } } if (part.Shape.SculptTexture != UUID.Zero) { assetRequestList.Add(part.Shape.SculptTexture); } } } } } } #endregion int entries_per_thread = (assetRequestList.Count / threads) + 1; UUID[] arrAssetRequestList = assetRequestList.ToArray(); List <UUID[]> arrvalus = new List <UUID[]>(); //split into separate arrays for (int j = 0; j < threads; j++) { List <UUID> val = new List <UUID>(); for (int k = j * entries_per_thread; k < ((j + 1) * entries_per_thread); k++) { if (k < arrAssetRequestList.Length) { val.Add(arrAssetRequestList[k]); } } arrvalus.Add(val.ToArray()); } for (int l = 0; l < arrvalus.Count; l++) { DecodeThreadContents threadworkItem = new DecodeThreadContents(); threadworkItem.sn = m_localScenes[0]; threadworkItem.j2kdecode = m_decoder; threadworkItem.arrassets = arrvalus[l]; System.Threading.Thread decodethread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(threadworkItem.run)); threadworkItem.SetThread(decodethread); decodethread.Priority = System.Threading.ThreadPriority.Lowest; decodethread.Name = "J2kCacheDecodeThread_" + l + 1; ThreadTracker.Add(decodethread); decodethread.Start(); } }
// Connect to the IRC server. A connector should always be connected, once enabled public void Connect() { if (!m_enabled) { return; } // Delay until next WD cycle if this is too close to the last start attempt while (_icc_ < ICCD_PERIOD) { return; } m_log.DebugFormat("[IRC-Connector-{0}]: Connection request for {1} on {2}:{3}", idn, m_nick, m_server, m_ircChannel); lock (msyncConnect) { _icc_ = 0; try { if (m_connected) { return; } m_connected = true; m_pending = true; m_timeout = L_TIMEOUT; m_tcp = new TcpClient(m_server, (int)m_port); m_stream = m_tcp.GetStream(); m_reader = new StreamReader(m_stream); m_writer = new StreamWriter(m_stream); m_log.InfoFormat("[IRC-Connector-{0}]: Connected to {1}:{2}", idn, m_server, m_port); m_listener = new Thread(new ThreadStart(ListenerRun)); m_listener.Name = "IRCConnectorListenerThread"; m_listener.IsBackground = true; m_listener.Start(); ThreadTracker.Add(m_listener); // This is the message order recommended by RFC 2812 if (m_password != null) { m_writer.WriteLine(String.Format("PASS {0}", m_password)); } m_writer.WriteLine(String.Format("NICK {0}", m_nick)); m_writer.Flush(); m_writer.WriteLine(m_user); m_writer.Flush(); m_writer.WriteLine(String.Format("JOIN {0}", m_ircChannel)); m_writer.Flush(); m_log.InfoFormat("[IRC-Connector-{0}]: {1} has asked to join {2}", idn, m_nick, m_ircChannel); } catch (Exception e) { m_log.ErrorFormat("[IRC-Connector-{0}] cannot connect {1} to {2}:{3}: {4}", idn, m_nick, m_server, m_port, e.Message); // It might seem reasonable to reset connected and pending status here // Seeing as we know that the login has failed, but if we do that, then // connection will be retried each time the interconnection interval // expires. By leaving them as they are, the connection will be retried // when the login timeout expires. Which is preferred. } } return; }