ThreadPool.h File Reference

#include "LinkedList.h"
#include <sys/time.h>
#include "FreeList.h"
#include "ithread.h"
#include <errno.h>

Go to the source code of this file.

Data Structures

struct  THREADPOOLATTR
struct  THREADPOOLJOB

Defines

#define JOBFREELISTSIZE   100
#define INFINITE_THREADS   -1
#define EMAXTHREADS   (-8 & 1<<29)
#define INVALID_POLICY   (-9 & 1<<29)
#define INVALID_JOB_ID   (-2 & 1<<29)
#define DEFAULT_PRIORITY   MED_PRIORITY
#define DEFAULT_MIN_THREADS   1
#define DEFAULT_MAX_THREADS   10
#define DEFAULT_JOBS_PER_THREAD   10
#define DEFAULT_STARVATION_TIME   500
#define DEFAULT_IDLE_TIME   10 * 1000
#define DEFAULT_FREE_ROUTINE   NULL
#define DEFAULT_MAX_JOBS_TOTAL   100
#define STATS   1
#define STATSONLY(x)   x
#define DBGONLY(x)
#define EXPORT
#define DEFAULT_POLICY   SCHED_OTHER
#define DEFAULT_SCHED_PARAM   0

Typedefs

typedef enum duration Duration
typedef enum priority ThreadPriority
typedef int PolicyType
typedef void(* free_routine )(void *arg)
typedef void(* free_thread_func )(void)
typedef struct THREADPOOLATTR ThreadPoolAttr
typedef struct THREADPOOLJOB ThreadPoolJob

Enumerations

enum  duration { SHORT_TERM, PERSISTENT }
enum  priority { LOW_PRIORITY, MED_PRIORITY, HIGH_PRIORITY }

Functions

 STATSONLY (typedef struct TPOOLSTATS{double totalTimeHQ;int totalJobsHQ;double avgWaitHQ;double totalTimeMQ;int totalJobsMQ;double avgWaitMQ;double totalTimeLQ;int totalJobsLQ;double avgWaitLQ;double totalWorkTime;double totalIdleTime;int workerThreads;int idleThreads;int persistentThreads;int totalThreads;int maxThreads;int currentJobsHQ;int currentJobsLQ;int currentJobsMQ;}ThreadPoolStats;) typedef struct THREADPOOL
int ThreadPoolInit (ThreadPool *tp, ThreadPoolAttr *attr)
int ThreadPoolAddPersistent (ThreadPool *tp, ThreadPoolJob *job, int *jobId)
int ThreadPoolGetAttr (ThreadPool *tp, ThreadPoolAttr *out)
int ThreadPoolSetAttr (ThreadPool *tp, ThreadPoolAttr *attr)
int ThreadPoolAdd (ThreadPool *tp, ThreadPoolJob *job, int *jobId)
int ThreadPoolRemove (ThreadPool *tp, int jobId, ThreadPoolJob *out)
int ThreadPoolShutdown (ThreadPool *tp)
int TPJobInit (ThreadPoolJob *job, start_routine func, void *arg)
int TPJobSetPriority (ThreadPoolJob *job, ThreadPriority priority)
int TPJobSetFreeFunction (ThreadPoolJob *job, free_routine func)
int TPAttrInit (ThreadPoolAttr *attr)
int TPAttrSetMaxThreads (ThreadPoolAttr *attr, int maxThreads)
int TPAttrSetMinThreads (ThreadPoolAttr *attr, int minThreads)
int TPAttrSetIdleTime (ThreadPoolAttr *attr, int idleTime)
int TPAttrSetJobsPerThread (ThreadPoolAttr *attr, int jobsPerThread)
int TPAttrSetStarvationTime (ThreadPoolAttr *attr, int starvationTime)
int TPAttrSetSchedPolicy (ThreadPoolAttr *attr, PolicyType schedPolicy)
int TPAttrSetMaxJobsTotal (ThreadPoolAttr *attr, int maxJobsTotal)
 STATSONLY (EXPORT int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats);)
 STATSONLY (EXPORT void ThreadPoolPrintStats(ThreadPoolStats *stats);)

Variables

 ThreadPool

Define Documentation

#define DBGONLY (  ) 

Definition at line 110 of file ThreadPool.h.

#define DEFAULT_FREE_ROUTINE   NULL

Definition at line 84 of file ThreadPool.h.

#define DEFAULT_IDLE_TIME   10 * 1000

Definition at line 83 of file ThreadPool.h.

#define DEFAULT_JOBS_PER_THREAD   10

Definition at line 81 of file ThreadPool.h.

#define DEFAULT_MAX_JOBS_TOTAL   100

Definition at line 85 of file ThreadPool.h.

#define DEFAULT_MAX_THREADS   10

Definition at line 80 of file ThreadPool.h.

#define DEFAULT_MIN_THREADS   1

Definition at line 79 of file ThreadPool.h.

#define DEFAULT_POLICY   SCHED_OTHER

Definition at line 122 of file ThreadPool.h.

#define DEFAULT_PRIORITY   MED_PRIORITY

Definition at line 78 of file ThreadPool.h.

#define DEFAULT_SCHED_PARAM   0

Definition at line 123 of file ThreadPool.h.

#define DEFAULT_STARVATION_TIME   500

Definition at line 82 of file ThreadPool.h.

#define EMAXTHREADS   (-8 & 1<<29)

Definition at line 64 of file ThreadPool.h.

#define EXPORT

Definition at line 120 of file ThreadPool.h.

#define INFINITE_THREADS   -1

Definition at line 62 of file ThreadPool.h.

#define INVALID_JOB_ID   (-2 & 1<<29)

Definition at line 70 of file ThreadPool.h.

#define INVALID_POLICY   (-9 & 1<<29)

Definition at line 67 of file ThreadPool.h.

#define JOBFREELISTSIZE   100

Definition at line 60 of file ThreadPool.h.

#define STATS   1

Definition at line 87 of file ThreadPool.h.

#define STATSONLY (  )     x

Definition at line 96 of file ThreadPool.h.


Typedef Documentation

typedef enum duration Duration
typedef void(* free_routine)(void *arg)

Definition at line 131 of file ThreadPool.h.

typedef void(* free_thread_func)(void)

Definition at line 132 of file ThreadPool.h.

typedef int PolicyType

Definition at line 121 of file ThreadPool.h.

typedef struct THREADPOOLJOB ThreadPoolJob
typedef enum priority ThreadPriority

Enumeration Type Documentation

enum duration
Enumerator:
SHORT_TERM 
PERSISTENT 

Definition at line 72 of file ThreadPool.h.

enum priority
Enumerator:
LOW_PRIORITY 
MED_PRIORITY 
HIGH_PRIORITY 

Definition at line 74 of file ThreadPool.h.


Function Documentation

STATSONLY ( EXPORT void ThreadPoolPrintStats(ThreadPoolStats *stats);   ) 
STATSONLY ( EXPORT int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats);   ) 
STATSONLY (  ) 

Definition at line 188 of file ThreadPool.h.

int ThreadPoolAdd ( ThreadPool tp,
ThreadPoolJob job,
int *  jobId 
)
int ThreadPoolAddPersistent ( ThreadPool tp,
ThreadPoolJob job,
int *  jobId 
)
int ThreadPoolGetAttr ( ThreadPool tp,
ThreadPoolAttr out 
)
int ThreadPoolInit ( ThreadPool tp,
ThreadPoolAttr attr 
)
int ThreadPoolRemove ( ThreadPool tp,
int  jobId,
ThreadPoolJob out 
)
int ThreadPoolSetAttr ( ThreadPool tp,
ThreadPoolAttr attr 
)
int ThreadPoolShutdown ( ThreadPool tp  ) 
int TPAttrInit ( ThreadPoolAttr attr  ) 
int TPAttrSetIdleTime ( ThreadPoolAttr attr,
int  idleTime 
)
int TPAttrSetJobsPerThread ( ThreadPoolAttr attr,
int  jobsPerThread 
)
int TPAttrSetMaxJobsTotal ( ThreadPoolAttr attr,
int  maxJobsTotal 
)
int TPAttrSetMaxThreads ( ThreadPoolAttr attr,
int  maxThreads 
)
int TPAttrSetMinThreads ( ThreadPoolAttr attr,
int  minThreads 
)
int TPAttrSetSchedPolicy ( ThreadPoolAttr attr,
PolicyType  schedPolicy 
)
int TPAttrSetStarvationTime ( ThreadPoolAttr attr,
int  starvationTime 
)
int TPJobInit ( ThreadPoolJob job,
start_routine  func,
void *  arg 
)
int TPJobSetFreeFunction ( ThreadPoolJob job,
free_routine  func 
)
int TPJobSetPriority ( ThreadPoolJob job,
ThreadPriority  priority 
)

Variable Documentation

Definition at line 260 of file ThreadPool.h.


Generated on Fri Mar 26 20:16:55 2010 for MediaTomb by  doxygen 1.6.1