THREADPOOL Struct Reference

A thread pool similar to the thread pool in the UPnP SDK. More...

`#include <ThreadPool.h>`

Collaboration diagram for THREADPOOL:
[legend]

## Data Fields

ithread_mutex_t | mutex
ithread_cond_t | condition
ithread_cond_t | start_and_shutdown
int | lastJobId
int | shutdown
int | totalThreads
int | pendingWorkerThreadStart
int | busyThreads
int | persistentThreads
FreeList | jobFreeList
LinkedList | lowJobQ
LinkedList | medJobQ
LinkedList | highJobQ
ThreadPoolJob * | persistentJob
ThreadPoolAttr | attr
ThreadPoolStats | stats

## Detailed Description

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.

## Field Documentation

## attr

ThreadPoolAttr THREADPOOL::attr

thread pool attributes

Referenced by AddWorker(), BumpPriority(), CreateWorker(), ThreadPoolAdd(), ThreadPoolAddPersistent(), ThreadPoolGetAttr(), ThreadPoolInit(), ThreadPoolSetAttr(), and WorkerThread().

## busyThreads

int THREADPOOL::busyThreads

number of threads that are currently executing jobs

Referenced by AddWorker(), ThreadPoolInit(), and WorkerThread().

## condition

ithread_cond_t THREADPOOL::condition

Condition variable to signal Q.

Referenced by ThreadPoolAdd(), ThreadPoolAddPersistent(), ThreadPoolInit(), ThreadPoolSetAttr(), ThreadPoolShutdown(), and WorkerThread().

## highJobQ

LinkedList THREADPOOL::highJobQ

high priority job Q

Referenced by AddWorker(), BumpPriority(), ThreadPoolAdd(), ThreadPoolGetStats(), ThreadPoolInit(), ThreadPoolRemove(), ThreadPoolShutdown(), and WorkerThread().

## jobFreeList

FreeList THREADPOOL::jobFreeList

free list of jobs

Referenced by CreateThreadPoolJob(), FreeThreadPoolJob(), ThreadPoolInit(), and ThreadPoolShutdown().

## lastJobId

int THREADPOOL::lastJobId

ids for jobs

Referenced by ThreadPoolAdd(), ThreadPoolAddPersistent(), and ThreadPoolInit().

## lowJobQ

LinkedList THREADPOOL::lowJobQ

low priority job Q

Referenced by AddWorker(), BumpPriority(), ThreadPoolAdd(), ThreadPoolGetStats(), ThreadPoolInit(), ThreadPoolRemove(), ThreadPoolShutdown(), and WorkerThread().

## medJobQ

LinkedList THREADPOOL::medJobQ

med priority job Q

Referenced by AddWorker(), BumpPriority(), ThreadPoolAdd(), ThreadPoolGetStats(), ThreadPoolInit(), ThreadPoolRemove(), ThreadPoolShutdown(), and WorkerThread().

## mutex

ithread_mutex_t THREADPOOL::mutex

Mutex to protect job qs.

Referenced by CreateWorker(), ThreadPoolAdd(), ThreadPoolAddPersistent(), ThreadPoolGetAttr(), ThreadPoolGetStats(), ThreadPoolInit(), ThreadPoolRemove(), ThreadPoolSetAttr(), ThreadPoolShutdown(), and WorkerThread().

## pendingWorkerThreadStart

int THREADPOOL::pendingWorkerThreadStart

flag that's set when waiting for a new worker thread to start

Referenced by CreateWorker(), ThreadPoolInit(), and WorkerThread().

## persistentJob

ThreadPoolJob* THREADPOOL::persistentJob

persistent job

Referenced by ThreadPoolAddPersistent(), ThreadPoolInit(), ThreadPoolRemove(), ThreadPoolShutdown(), and WorkerThread().

## persistentThreads

int THREADPOOL::persistentThreads

number of persistent threads

Referenced by AddWorker(), ThreadPoolAddPersistent(), ThreadPoolGetStats(), ThreadPoolInit(), and WorkerThread().

## shutdown

int THREADPOOL::shutdown

whether or not we are shutting down

Referenced by ThreadPoolGetAttr(), ThreadPoolGetStats(), ThreadPoolInit(), ThreadPoolShutdown(), and WorkerThread().

## start_and_shutdown

ithread_cond_t THREADPOOL::start_and_shutdown

Condition variable for start and stop.

Referenced by CreateWorker(), ThreadPoolAddPersistent(), ThreadPoolInit(), ThreadPoolShutdown(), and WorkerThread().

## stats

ThreadPoolStats THREADPOOL::stats

statistics

Referenced by CreateWorker(), StatsAccountHQ(), StatsAccountLQ(), StatsAccountMQ(), ThreadPoolGetStats(), ThreadPoolInit(), and WorkerThread().

## totalThreads

int THREADPOOL::totalThreads

total number of threads

Referenced by AddWorker(), CreateWorker(), ThreadPoolAddPersistent(), ThreadPoolGetStats(), ThreadPoolInit(), ThreadPoolSetAttr(), ThreadPoolShutdown(), and WorkerThread().

The documentation for this struct was generated from the following file:

- /build/pupnp-EKUuah/pupnp-1.14.18/upnp/src/threadutil/ThreadPool.h