public PollServiceRequestManager( BaseHttpServer pSrv, bool performResponsesAsync, uint pWorkerThreadCount, int pTimeout) { m_server = pSrv; PerformResponsesAsync = performResponsesAsync; m_WorkerThreadCount = pWorkerThreadCount; m_workerThreads = new Thread[m_WorkerThreadCount]; StatsManager.RegisterStat( new Stat( "QueuedPollResponses", "Number of poll responses queued for processing.", "", "", "httpserver", m_server.Port.ToString(), StatType.Pull, MeasuresOfInterest.AverageChangeOverTime, stat => stat.Value = m_requests.Count(), StatVerbosity.Debug)); StatsManager.RegisterStat( new Stat( "ProcessedPollResponses", "Number of poll responses processed.", "", "", "httpserver", m_server.Port.ToString(), StatType.Pull, MeasuresOfInterest.AverageChangeOverTime, stat => stat.Value = ResponsesProcessed, StatVerbosity.Debug)); }
public void Stop() { m_running = false; Thread.Sleep(1000); // let the world move foreach (Thread t in m_workerThreads) { Watchdog.AbortThread(t.ManagedThreadId); } // any entry in m_bycontext should have a active request on the other queues // so just delete contents to easy GC foreach (Queue <PollServiceHttpRequest> qu in m_bycontext.Values) { qu.Clear(); } m_bycontext.Clear(); try { foreach (PollServiceHttpRequest req in m_retryRequests) { req.DoHTTPstop(m_server); } } catch { } PollServiceHttpRequest wreq; m_retryRequests.Clear(); lock (m_slowRequests) { while (m_slowRequests.Count > 0) { m_requests.Enqueue(m_slowRequests.Dequeue()); } } while (m_requests.Count() > 0) { try { wreq = m_requests.Dequeue(0); wreq.DoHTTPstop(m_server); } catch { } } m_requests.Clear(); }
public void Update() { if (msgQueue.Count() > 0) { Message msg = msgQueue.Dequeue(); if (msg != null) { luaMsgDispatcher(msg.Content); } } }
public void Stop() { if (m_log.IsDebugEnabled) { m_log.DebugFormat("{0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); } m_running = false; // m_timeout = -10000; // cause all to expire Thread.Sleep(1000); // let the world move foreach (Thread t in m_workerThreads) { Watchdog.AbortThread(t.ManagedThreadId); } PollServiceHttpRequest wreq; lock (m_longPollRequests) { if (m_longPollRequests.Count > 0 && m_running) { m_longPollRequests.ForEach(req => m_requests.Enqueue(req)); } } while (m_requests.Count() > 0) { try { wreq = m_requests.Dequeue(0); wreq.DoHTTPGruntWork( m_server, wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id)); } catch { } } m_longPollRequests.Clear(); m_requests.Clear(); }
/// <summary> /// Does the asset server have any waiting requests? /// </summary> /// /// This does include any request that is currently being handled. This information is not reliable where /// another thread may be processing requests. /// /// <returns> /// True if there are waiting requests. False if there are no waiting requests. /// </returns> public virtual bool HasWaitingRequests() { return(m_assetRequests.Count() != 0); }