Functions | |
Scope restricted to file | |
long | DiffMillis (timeval *time1, timeval *time2) |
Returns the difference in milliseconds between two timeval structures. | |
void | StatsInit (ThreadPoolStats *stats) |
Initializes the statistics structure. | |
void | StatsAccountLQ (ThreadPool *tp, long diffTime) |
StatsAccountLQ. | |
void | StatsAccountMQ (ThreadPool *tp, long diffTime) |
StatsAccountMQ. | |
void | StatsAccountHQ (ThreadPool *tp, long diffTime) |
StatsAccountHQ. | |
void | CalcWaitTime (ThreadPool *tp, ThreadPriority p, ThreadPoolJob *job) |
Calculates the time the job has been waiting at the specified priority. | |
time_t | StatsTime (time_t *t) |
StatsTime. | |
int | CmpThreadPoolJob (void *jobA, void *jobB) |
Compares thread pool jobs. | |
void | FreeThreadPoolJob (ThreadPool *tp, ThreadPoolJob *tpj) |
Deallocates a dynamically allocated ThreadPoolJob. | |
int | SetPolicyType (PolicyType in) |
Sets the scheduling policy of the current process. | |
int | SetPriority (ThreadPriority priority) |
Sets the priority of the currently running thread. | |
void | BumpPriority (ThreadPool *tp) |
Determines whether any jobs need to be bumped to a higher priority Q and bumps them. | |
void | SetRelTimeout (timespec *time, int relMillis) |
Sets the fields of the passed in timespec to be relMillis milliseconds in the future. | |
void | SetSeed (void) |
Sets seed for random number generator. | |
void * | WorkerThread (void *arg) |
Implements a thread pool worker. | |
ThreadPoolJob * | CreateThreadPoolJob (ThreadPoolJob *job, int id, ThreadPool *tp) |
Creates a Thread Pool Job. (Dynamically allocated) | |
int | CreateWorker (ThreadPool *tp) |
Creates a worker thread, if the thread pool does not already have max threads. | |
void | AddWorker (ThreadPool *tp) |
Determines whether or not a thread should be added based on the jobsPerThread ratio. | |
long anonymous_namespace{ThreadPool.cpp}::DiffMillis | ( | timeval * | time1, |
timeval * | time2 | ||
) |
Returns the difference in milliseconds between two timeval structures.
Definition at line 75 of file ThreadPool.cpp.
void anonymous_namespace{ThreadPool.cpp}::StatsInit | ( | ThreadPoolStats * | stats | ) |
Initializes the statistics structure.
stats | Valid non null stats structure. |
Definition at line 93 of file ThreadPool.cpp.
void anonymous_namespace{ThreadPool.cpp}::StatsAccountLQ | ( | ThreadPool * | tp, |
long | diffTime | ||
) |
StatsAccountLQ.
[in] | tp | Valid, non null, pointer to ThreadPool. |
diffTime | . |
Definition at line 118 of file ThreadPool.cpp.
void anonymous_namespace{ThreadPool.cpp}::StatsAccountMQ | ( | ThreadPool * | tp, |
long | diffTime | ||
) |
StatsAccountMQ.
[in] | tp | Valid, non null, pointer to ThreadPool. |
diffTime | . |
Definition at line 130 of file ThreadPool.cpp.
void anonymous_namespace{ThreadPool.cpp}::StatsAccountHQ | ( | ThreadPool * | tp, |
long | diffTime | ||
) |
StatsAccountHQ.
[in] | tp | Valid, non null, pointer to ThreadPool. |
diffTime | . |
Definition at line 142 of file ThreadPool.cpp.
void anonymous_namespace{ThreadPool.cpp}::CalcWaitTime | ( | ThreadPool * | tp, |
ThreadPriority | p, | ||
ThreadPoolJob * | job | ||
) |
Calculates the time the job has been waiting at the specified priority.
Adds to the totalTime and totalJobs kept in the thread pool statistics structure.
[in] | tp | Valid, non null, pointer to ThreadPool. |
[in] | p | Thread priority. |
[in] | job | Valid thread pool job. |
Definition at line 158 of file ThreadPool.cpp.
time_t anonymous_namespace{ThreadPool.cpp}::StatsTime | ( | time_t * | t | ) |
StatsTime.
t | . |
Definition at line 191 of file ThreadPool.cpp.
int anonymous_namespace{ThreadPool.cpp}::CmpThreadPoolJob | ( | void * | jobA, |
void * | jobB | ||
) |
Compares thread pool jobs.
Definition at line 215 of file ThreadPool.cpp.
void anonymous_namespace{ThreadPool.cpp}::FreeThreadPoolJob | ( | ThreadPool * | tp, |
ThreadPoolJob * | tpj | ||
) |
Deallocates a dynamically allocated ThreadPoolJob.
[in] | tp | Valid, non null, pointer to ThreadPool. |
[in] | tpj | Must be allocated with CreateThreadPoolJob. |
Definition at line 225 of file ThreadPool.cpp.
int anonymous_namespace{ThreadPool.cpp}::SetPolicyType | ( | PolicyType | in | ) |
Sets the scheduling policy of the current process.
in | . |
Definition at line 240 of file ThreadPool.cpp.
int anonymous_namespace{ThreadPool.cpp}::SetPriority | ( | ThreadPriority | priority | ) |
Sets the priority of the currently running thread.
[in] | priority | Thread priority |
Definition at line 276 of file ThreadPool.cpp.
void anonymous_namespace{ThreadPool.cpp}::BumpPriority | ( | ThreadPool * | tp | ) |
Determines whether any jobs need to be bumped to a higher priority Q and bumps them.
tp->mutex must be locked.
[in] | tp | Valid, non null, pointer to ThreadPool. |
Definition at line 327 of file ThreadPool.cpp.
void anonymous_namespace{ThreadPool.cpp}::SetRelTimeout | ( | timespec * | time, |
int | relMillis | ||
) |
Sets the fields of the passed in timespec to be relMillis milliseconds in the future.
time | . |
relMillis | milliseconds in the future. |
Definition at line 369 of file ThreadPool.cpp.
void anonymous_namespace{ThreadPool.cpp}::SetSeed | ( | void | ) |
Sets seed for random number generator.
Each thread sets the seed random number generator.
Definition at line 390 of file ThreadPool.cpp.
void * anonymous_namespace{ThreadPool.cpp}::WorkerThread | ( | void * | arg | ) |
Implements a thread pool worker.
Worker waits for a job to become available. Worker picks up persistent jobs first, high priority, med priority, then low priority. If worker remains idle for more than specified max, the worker is released.
arg | arg -> is cast to (ThreadPool *). |
Definition at line 423 of file ThreadPool.cpp.
ThreadPoolJob * anonymous_namespace{ThreadPool.cpp}::CreateThreadPoolJob | ( | ThreadPoolJob * | job, |
int | id, | ||
ThreadPool * | tp | ||
) |
Creates a Thread Pool Job. (Dynamically allocated)
job | job is copied. | |
id | id of job. | |
[in] | tp | Valid, non null, pointer to ThreadPool. |
Definition at line 571 of file ThreadPool.cpp.
int anonymous_namespace{ThreadPool.cpp}::CreateWorker | ( | ThreadPool * | tp | ) |
Creates a worker thread, if the thread pool does not already have max threads.
[in] | tp | Valid, non null, pointer to ThreadPool. |
Definition at line 603 of file ThreadPool.cpp.
void anonymous_namespace{ThreadPool.cpp}::AddWorker | ( | ThreadPool * | tp | ) |
Determines whether or not a thread should be added based on the jobsPerThread ratio.
Adds a thread if appropriate.
[in] | tp | Valid, non null, pointer to ThreadPool. |
Definition at line 648 of file ThreadPool.cpp.