SourceMod SDK  1.7
SourceMod::IThreadWorker Class Referenceabstract

This is a "worker pool." A single thread places tasks in a queue. Each IThread is then a task, rather than its own separate thread. More...

#include <public/IThreader.h>

Inheritance diagram for SourceMod::IThreadWorker:
SourceMod::IThreadCreator

Public Member Functions

virtual ~IThreadWorker ()
 
virtual unsigned int RunFrame ()=0
 Runs one "frame" of the worker. More...
 
virtual bool Pause ()=0
 Pauses the worker. More...
 
virtual bool Unpause ()=0
 Unpauses the worker. More...
 
virtual bool Start ()=0
 Starts the worker thread. More...
 
virtual bool Stop (bool flush)=0
 Stops the worker thread. More...
 
virtual WorkerState GetStatus (unsigned int *numThreads)=0
 Returns the status of the worker. More...
 
virtual void SetMaxThreadsPerFrame (unsigned int threads)=0
 Sets the number of threads to run per frame. Default value is 1 thread per frame. More...
 
virtual void SetThinkTimePerFrame (unsigned int thinktime)=0
 For threaded workers, the think time of a frame. Has no effect for non-threaded workers. Default value is 50ms. More...
 
- Public Member Functions inherited from SourceMod::IThreadCreator
virtual ~IThreadCreator ()
 
virtual void MakeThread (IThread *pThread)=0
 Creates a basic thread. More...
 
virtual IThreadHandleMakeThread (IThread *pThread, ThreadFlags flags)=0
 Creates a thread with specific options. More...
 
virtual IThreadHandleMakeThread (IThread *pThread, const ThreadParams *params)=0
 Creates a thread with specific options. More...
 
virtual void GetPriorityBounds (ThreadPriority &max, ThreadPriority &min)=0
 Returns the priority bounds. Note: On Linux, the min and max are both Thread_Normal. More...
 

Detailed Description

This is a "worker pool." A single thread places tasks in a queue. Each IThread is then a task, rather than its own separate thread.

Constructor & Destructor Documentation

virtual SourceMod::IThreadWorker::~IThreadWorker ( )
inlinevirtual

Virtual Destructor

Member Function Documentation

virtual WorkerState SourceMod::IThreadWorker::GetStatus ( unsigned int *  numThreads)
pure virtual

Returns the status of the worker.

Parameters
numThreadsPointer to store number of threads in the queue.
Returns
State of the worker.
virtual bool SourceMod::IThreadWorker::Pause ( )
pure virtual

Pauses the worker.

Returns
True on success, false otherwise.
virtual unsigned int SourceMod::IThreadWorker::RunFrame ( )
pure virtual

Runs one "frame" of the worker.

Returns
Number of tasks processed.
virtual void SourceMod::IThreadWorker::SetMaxThreadsPerFrame ( unsigned int  threads)
pure virtual

Sets the number of threads to run per frame. Default value is 1 thread per frame.

Parameters
threadsNumber of threads to run per frame.
virtual void SourceMod::IThreadWorker::SetThinkTimePerFrame ( unsigned int  thinktime)
pure virtual

For threaded workers, the think time of a frame. Has no effect for non-threaded workers. Default value is 50ms.

Parameters
thinktimeNumber of ms to sleep between frame execution.
virtual bool SourceMod::IThreadWorker::Start ( )
pure virtual

Starts the worker thread.

Returns
True on success, false otherwise.
virtual bool SourceMod::IThreadWorker::Stop ( bool  flush)
pure virtual

Stops the worker thread.

Parameters
flushIf true, all remaining tasks will be cancelled. Otherwise, the threader will wait until the queue is empty.
Returns
True on success, false otherwise.
virtual bool SourceMod::IThreadWorker::Unpause ( )
pure virtual

Unpauses the worker.

Returns
True on success, false otherwise.

The documentation for this class was generated from the following file: