You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nvidia-texture-tools/src/nvthread/ParallelFor.h

39 lines
817 B
C++

// This code is in the public domain -- Ignacio Castaño <castano@gmail.com>
#pragma once
#ifndef NV_THREAD_PARALLELFOR_H
#define NV_THREAD_PARALLELFOR_H
#include "nvthread.h"
//#include "Atomic.h" // atomic<uint>
namespace nv
{
class Thread;
class ThreadPool;
typedef void ForTask(void * context, int id);
struct ParallelFor {
ParallelFor(ForTask * task, void * context);
~ParallelFor();
void run(uint count, bool calling_thread_process_work = false);
// Invariant:
ForTask * task;
void * context;
ThreadPool * pool;
//uint workerCount; // @@ Move to thread pool.
//Thread * workers;
// State:
uint count;
/*atomic<uint>*/ uint idx;
};
} // nv namespace
#endif // NV_THREAD_PARALLELFOR_H