QTrk
Classes | Typedefs | Functions
threads.h File Reference
#include <list>
#include <Windows.h>

Go to the source code of this file.

Classes

struct  Threads
 Thread OS related code is abstracted into a simple "Threads" struct. More...
 
struct  Threads::Handle
 
struct  Threads::Mutex
 
class  Atomic< T >
 
class  ThreadPool< TWorkItem, TFunctor >
 

Typedefs

typedef Threads::Handle ThreadHandle
 

Functions

template<typename TF >
void parallel_for (int count, TF f)
 

Typedef Documentation

§ ThreadHandle

Definition at line 150 of file threads.h.

Function Documentation

§ parallel_for()

template<typename TF >
void parallel_for ( int  count,
TF  f 
)

Definition at line 251 of file threads.h.

251  {
252 
253  if (count == 1)
254  f(0);
255  else {
256  ThreadPool<int, TF> threadPool(f, std::min (count, Threads::GetCPUCount()) );
257  for (int i=0;i<count;i++) threadPool.AddWork(i);
258  threadPool.WaitUntilDone();
259  }
260 }
static int GetCPUCount()
Definition: threads.h:138