Made thread worker processing limits configurable at runtime (bug 5326, r=psychonic).

This commit is contained in:
Asher Baker
2012-12-14 15:16:35 -05:00
parent e77ad244ad
commit 439986e3fe
5 changed files with 28 additions and 9 deletions
+1 -6
View File
@@ -124,11 +124,6 @@ void BaseWorker::AddThreadToQueue(SWThreadHandle *pHandle)
m_ThreadQueue.push_back(pHandle);
}
unsigned int BaseWorker::GetMaxThreadsPerFrame()
{
return m_perFrame;
}
WorkerState BaseWorker::GetStatus(unsigned int *threads)
{
if (threads)
@@ -140,7 +135,7 @@ WorkerState BaseWorker::GetStatus(unsigned int *threads)
unsigned int BaseWorker::RunFrame()
{
unsigned int done = 0;
unsigned int max = GetMaxThreadsPerFrame();
unsigned int max = m_perFrame;
SWThreadHandle *swt = NULL;
IThread *pThread = NULL;
+2 -2
View File
@@ -84,6 +84,8 @@ public: //IWorker
virtual unsigned int Flush(bool flush_cancel);
//returns status and number of threads in queue
virtual WorkerState GetStatus(unsigned int *numThreads);
virtual void SetMaxThreadsPerFrame(unsigned int threads);
virtual void SetThinkTimePerFrame(unsigned int thinktime) {}
public: //IThreadCreator
virtual void MakeThread(IThread *pThread);
virtual IThreadHandle *MakeThread(IThread *pThread, ThreadFlags flags);
@@ -92,8 +94,6 @@ public: //IThreadCreator
public: //BaseWorker
virtual void AddThreadToQueue(SWThreadHandle *pHandle);
virtual SWThreadHandle *PopThreadFromQueue();
virtual void SetMaxThreadsPerFrame(unsigned int threads);
virtual unsigned int GetMaxThreadsPerFrame();
protected:
SourceHook::List<SWThreadHandle *> m_ThreadQueue;
unsigned int m_perFrame;
+5
View File
@@ -209,6 +209,11 @@ WorkerState ThreadWorker::GetStatus(unsigned int *threads)
return state;
}
void ThreadWorker::SetThinkTimePerFrame(unsigned int thinktime)
{
m_think_time = thinktime;
}
bool ThreadWorker::Start()
{
if (m_state == Worker_Invalid)
+2
View File
@@ -53,6 +53,8 @@ public: //IWorker
virtual bool Stop(bool flush_cancel);
//returns status and number of threads in queue
virtual WorkerState GetStatus(unsigned int *numThreads);
//virtual void SetMaxThreadsPerFrame(unsigned int threads);
virtual void SetThinkTimePerFrame(unsigned int thinktime);
public: //BaseWorker
virtual void AddThreadToQueue(SWThreadHandle *pHandle);
virtual SWThreadHandle *PopThreadFromQueue();