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/ThreadPool.h

50 lines
899 B
C++

// This code is in the public domain -- castano@gmail.com
#pragma once
#ifndef NV_THREAD_THREADPOOL_H
#define NV_THREAD_THREADPOOL_H
#include "nvthread.h"
#include "Event.h"
#include "Thread.h"
namespace nv {
class Thread;
class Event;
class ThreadPool {
NV_FORBID_COPY(ThreadPool);
public:
static ThreadPool * acquire();
static void release(ThreadPool *);
ThreadPool();
~ThreadPool();
void start(ThreadFunc * func, void * arg);
void wait();
private:
static void workerFunc(void * arg);
uint workerCount;
Thread * workers;
Event * startEvents;
Event * finishEvents;
uint allIdle;
// Current function:
ThreadFunc * func;
void * arg;
};
} // namespace nv
#endif // NV_THREAD_THREADPOOL_H