TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
G3D::_internalGThreadWorker< Class > Class Template Reference

#include <GThread.h>

Public Member Functions

 _internalGThreadWorker (int threadID, const Vector2int32 &start, const Vector2int32 &upTo, Class *object, void(Class::*method1)(int x, int y), void(Class::*method2)(int x, int y, int threadID), const Vector2int32 &stride)
 
virtual void threadMain ()
 
- Public Member Functions inherited from G3D::GThread
 GThread (const std::string &name)
 
virtual ~GThread ()
 
bool start (SpawnBehavior behavior=USE_NEW_THREAD)
 
void terminate ()
 
bool running () const
 
bool started () const
 
bool completed () const
 
void waitForCompletion ()
 
const std::string & name ()
 
- Public Member Functions inherited from G3D::ReferenceCountedObject
virtual ~ReferenceCountedObject ()
 

Public Attributes

const int threadID
 
const Vector2int32 start
 
const Vector2int32 upTo
 
const Vector2int32 stride
 
Class * object
 
void(Class::* method1 )(int x, int y)
 
void(Class::* method2 )(int x, int y, int threadID)
 

Additional Inherited Members

- Public Types inherited from G3D::GThread
enum  { NUM_CORES = -100 }
 
typedef shared_ptr< class GThreadRef
 
- Static Public Member Functions inherited from G3D::GThread
static int numCores ()
 
static GThreadRef create (const std::string &name, void(*proc)(void *), void *param=NULL)
 
template<class Class >
static void runConcurrently2D (const Vector2int32 &start, const Vector2int32 &upTo, Class *object, void(Class::*method)(int x, int y), int maxThreads=NUM_CORES)
 Iterates over a 2D region using multiple threads and blocks until all threads have completed. More...
 
template<class Class >
static void runConcurrently2D (const Vector2int32 &start, const Vector2int32 &upTo, Class *object, void(Class::*method)(int x, int y, int threadID), int maxThreads=NUM_CORES)
 
- Static Public Attributes inherited from G3D::GThread
static const SpawnBehavior USE_CURRENT_THREAD = G3D::USE_CURRENT_THREAD
 
static const SpawnBehavior USE_NEW_THREAD = G3D::USE_NEW_THREAD
 

Detailed Description

template<class Class>
class G3D::_internalGThreadWorker< Class >

For use by runConcurrently2D. Designed for arbitrary iteration, although only used for interlaced rows in the current implementation.

Constructor & Destructor Documentation

template<class Class >
G3D::_internalGThreadWorker< Class >::_internalGThreadWorker ( int  threadID,
const Vector2int32 start,
const Vector2int32 upTo,
Class *  object,
void(Class::*)(int x, int y method1,
void(Class::*)(int x, int y, int threadID method2,
const Vector2int32 stride 
)
inline
212  :
213  GThread("runConcurrently2D worker"),
215  start(start),
216  upTo(upTo),
217  stride(stride),
218  object(object),
219  method1(method1),
220  method2(method2) {}
void(Class::* method1)(int x, int y)
Definition: GThread.h:203
void(Class::* method2)(int x, int y, int threadID)
Definition: GThread.h:204
GThread(const GThread &)
const Vector2int32 start
Definition: GThread.h:199
const int threadID
Definition: GThread.h:198
Class * object
Definition: GThread.h:202
const Vector2int32 upTo
Definition: GThread.h:200
const Vector2int32 stride
Definition: GThread.h:201

Member Function Documentation

template<class Class >
virtual void G3D::_internalGThreadWorker< Class >::threadMain ( )
inlinevirtual

Overriden by the thread implementor

Implements G3D::GThread.

222  {
223  for (int y = start.y; y < upTo.y; y += stride.y) {
224  // Run whichever method was provided
225  if (method1) {
226  for (int x = start.x; x < upTo.x; x += stride.x) {
227  (object->*method1)(x, y);
228  }
229  } else {
230  for (int x = start.x; x < upTo.x; x += stride.x) {
231  (object->*method2)(x, y, threadID);
232  }
233  }
234  }
235  }
void(Class::* method1)(int x, int y)
Definition: GThread.h:203
void(Class::* method2)(int x, int y, int threadID)
Definition: GThread.h:204
const Vector2int32 start
Definition: GThread.h:199
const int threadID
Definition: GThread.h:198
G3D::int16 y
Definition: Vector2int16.h:38
const Vector2int32 upTo
Definition: GThread.h:200
G3D::int16 x
Definition: Vector2int16.h:37
const Vector2int32 stride
Definition: GThread.h:201

Member Data Documentation

template<class Class >
void(Class::* G3D::_internalGThreadWorker< Class >::method1)(int x, int y)
template<class Class >
void(Class::* G3D::_internalGThreadWorker< Class >::method2)(int x, int y, int threadID)
template<class Class >
Class* G3D::_internalGThreadWorker< Class >::object
template<class Class >
const Vector2int32 G3D::_internalGThreadWorker< Class >::start
template<class Class >
const Vector2int32 G3D::_internalGThreadWorker< Class >::stride
template<class Class >
const int G3D::_internalGThreadWorker< Class >::threadID

Start for this thread, which differs from the others

template<class Class >
const Vector2int32 G3D::_internalGThreadWorker< Class >::upTo

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