2#ifndef INTERFACE_THREADPOOL_HPP
3#define INTERFACE_THREADPOOL_HPP
50class CThreadPool :
public IThreadPool {
53 return ::ThreadPoolInit(tp, attr);
56 return ::ThreadPoolAddPersistent(tp, job, jobId);
59 return ::ThreadPoolAdd(tp, job, jobId);
62 return ::ThreadPoolRemove(tp, jobId, out);
65 return ::ThreadPoolGetAttr(tp, out);
68 return ::ThreadPoolSetAttr(tp, attr);
71 return ::ThreadPoolShutdown(tp);
74 return ::TPAttrInit(attr);
77 return ::TPJobInit(job, func, arg);
80 return ::TPJobSetPriority(job, priority);
83 return ::TPJobSetFreeFunction(job, func);
86 return ::TPAttrSetMaxThreads(attr, maxThreads);
89 return ::TPAttrSetMinThreads(attr, minThreads);
92 return ::TPAttrSetStackSize(attr, stackSize);
95 return ::TPAttrSetIdleTime(attr, idleTime);
98 return ::TPAttrSetJobsPerThread(attr, jobsPerThread);
101 return ::TPAttrSetStarvationTime(attr, starvationTime);
104 return ::TPAttrSetSchedPolicy(attr, schedPolicy);
107 return ::TPAttrSetMaxJobsTotal(attr, totalMaxJobs);
110 return ::ThreadPoolPrintStats(stats);
113 return ::ThreadPoolGetStats(tp, stats);
116 return ::gettimeofday(tv, tz);
int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr)
Initializes and starts ThreadPool.
int ThreadPoolAdd(ThreadPool *tp, ThreadPoolJob *job, int *jobId)
Adds a job to the thread pool.
int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func)
Sets the jobs free function.
int ThreadPoolShutdown(ThreadPool *tp)
Shuts the thread pool down.
int ThreadPoolGetAttr(ThreadPool *tp, ThreadPoolAttr *out)
Gets the current set of attributes associated with the thread pool.
void ThreadPoolPrintStats(ThreadPoolStats *stats)
Prints various statistics about the thread pool to stderr.
int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int totalMaxJobs)
Sets the maximum number jobs that can be qeued totally.
int TPAttrSetStarvationTime(ThreadPoolAttr *attr, int starvationTime)
Sets the starvation time for the thread pool attributes.
int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads)
Sets the max threads for the thread pool attributes.
int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority)
Sets the priority of the threadpool job.
int ThreadPoolSetAttr(ThreadPool *tp, ThreadPoolAttr *attr)
Sets the attributes for the thread pool.
int ThreadPoolRemove(ThreadPool *tp, int jobId, ThreadPoolJob *out)
Removes a job from the thread pool.
int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats)
Returns various statistics about the thread pool.
int TPAttrSetJobsPerThread(ThreadPoolAttr *attr, int jobsPerThread)
Sets the jobs per thread ratio.
int gettimeofday(struct timeval *tv, struct timezone *tz)
Get time of day.
int TPJobInit(ThreadPoolJob *job, UPnPsdk::start_routine func, void *arg)
Initializes thread pool job.
int TPAttrInit(ThreadPoolAttr *attr)
Initializes thread pool attributes.
int TPAttrSetIdleTime(ThreadPoolAttr *attr, int idleTime)
Sets the idle time for the thread pool attributes.
int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads)
Sets the min threads for the thread pool attributes.
int TPAttrSetSchedPolicy(ThreadPoolAttr *attr, PolicyType schedPolicy)
Sets the scheduling policy for the thread pool attributes.
int TPAttrSetStackSize(ThreadPoolAttr *attr, size_t stackSize)
Sets the stack size for the thread pool attributes.
int ThreadPoolAddPersistent(ThreadPool *tp, ThreadPoolJob *job, int *jobId)
Adds a persistent job to the thread pool.
Manage a threadpool (for internal use only).
int PolicyType
Type of the thread policy.
ThreadPriority
Thread priority.
void(* free_routine)(void *arg)
Structure to hold statistics.
Attributes for thread pool.