libUPnP
1.8.0
|
#include "FreeList.h"
#include "ithread.h"
#include "LinkedList.h"
#include "UpnpInet.h"
#include "UpnpGlobal.h"
#include <errno.h>
#include <sys/param.h>
#include <sys/time.h>
Go to the source code of this file.
Data Structures | |
struct | THREADPOOLATTR |
struct | THREADPOOLJOB |
struct | TPOOLSTATS |
struct | THREADPOOL |
A thread pool similar to the thread pool in the UPnP SDK. More... |
Macros | |
#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 |
Statistics. | |
#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 struct THREADPOOLATTR | ThreadPoolAttr |
typedef struct THREADPOOLJOB | ThreadPoolJob |
typedef struct TPOOLSTATS | ThreadPoolStats |
typedef struct THREADPOOL | ThreadPool |
A thread pool similar to the thread pool in the UPnP SDK. |
Enumerations | |
enum | duration { SHORT_TERM, PERSISTENT } |
enum | priority { LOW_PRIORITY, MED_PRIORITY, HIGH_PRIORITY } |
Functions | |
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) |
int | ThreadPoolGetStats (ThreadPool *tp, ThreadPoolStats *stats) |
void | ThreadPoolPrintStats (ThreadPoolStats *stats) |
#define DEFAULT_FREE_ROUTINE NULL |
default free routine used TPJobInit
#define DEFAULT_IDLE_TIME 10 * 1000 |
default idle time used by TPAttrInit
#define DEFAULT_JOBS_PER_THREAD 10 |
default jobs per thread used by TPAttrInit
#define DEFAULT_MAX_JOBS_TOTAL 100 |
default max jobs used TPAttrInit
#define DEFAULT_MAX_THREADS 10 |
default max used by TPAttrInit
#define DEFAULT_MIN_THREADS 1 |
default minimum used by TPAttrInit
#define DEFAULT_PRIORITY MED_PRIORITY |
default priority used by TPJobInit
#define DEFAULT_SCHED_PARAM 0 |
Default priority
#define DEFAULT_STARVATION_TIME 500 |
default starvation time used by TPAttrInit
#define INVALID_JOB_ID (-2 & 1<<29) |
Invalid JOB Id
#define INVALID_POLICY (-9 & 1<<29) |
Invalid Policy
#define JOBFREELISTSIZE 100 |
Size of job free list
#define STATS 1 |
Statistics.
Always include stats because code change is minimal.
typedef struct THREADPOOL ThreadPool |
A thread pool similar to the thread pool in the UPnP SDK.
Allows jobs to be scheduled for running by threads in a thread pool. The thread pool is initialized with a minimum and maximum thread number as well as a max idle time and a jobs per thread ratio. If a worker thread waits the whole max idle time without receiving a job and the thread pool currently has more threads running than the minimum then the worker thread will exit. If when scheduling a job the current job to thread ratio becomes greater than the set ratio and the thread pool currently has less than the maximum threads then a new thread will be created.