59 int gettimeofday(
struct timeval *tv,
struct timezone *tz);
61 #include <sys/param.h>
63 #if defined(__OSX__) || defined(__APPLE__) || defined(__NetBSD__)
64 #include <sys/resource.h>
76 #define JOBFREELISTSIZE 100
79 #define INFINITE_THREADS -1
82 #define EMAXTHREADS (-8 & 1<<29)
86 #define INVALID_POLICY (-9 & 1<<29)
90 #define INVALID_JOB_ID (-2 & 1<<29)
93 typedef enum duration {
99 typedef enum priority {
107 #define DEFAULT_PRIORITY MED_PRIORITY
111 #define DEFAULT_MIN_THREADS 1
115 #define DEFAULT_MAX_THREADS 10
119 #define DEFAULT_JOBS_PER_THREAD 10
123 #define DEFAULT_STARVATION_TIME 500
127 #define DEFAULT_IDLE_TIME 10 * 1000
131 #define DEFAULT_FREE_ROUTINE NULL
135 #define DEFAULT_MAX_JOBS_TOTAL 100
151 typedef int PolicyType;
154 #define DEFAULT_POLICY SCHED_OTHER
158 #define DEFAULT_SCHED_PARAM 0
167 typedef void (*free_routine)(
void *arg);
200 PolicyType schedPolicy;
214 free_routine free_func;
215 struct timeval requestTime;
238 double totalWorkTime;
239 double totalIdleTime;
242 int persistentThreads;
268 ithread_mutex_t mutex;
269 ithread_cond_t condition;
270 ithread_cond_t start_and_shutdown;
275 int persistentThreads;
452 int TPJobInit(
ThreadPoolJob *job, start_routine func,
void *arg);
466 int TPJobSetPriority(
ThreadPoolJob *job, ThreadPriority priority);
480 int TPJobSetFreeFunction(
ThreadPoolJob *job, free_routine func);
549 int TPAttrSetJobsPerThread(
ThreadPoolAttr *attr,
int jobsPerThread);
563 int TPAttrSetStarvationTime(
ThreadPoolAttr *attr,
int starvationTime);
577 int TPAttrSetSchedPolicy(
ThreadPoolAttr *attr, PolicyType schedPolicy);
591 int TPAttrSetMaxJobsTotal(
ThreadPoolAttr *attr,
int maxJobsTotal);