Tor 0.4.9.3-alpha-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Fields
threadpool_t Struct Reference

Data Fields

struct workerthread_t ** threads
 
tor_cond_t condition
 
work_tailq_t work [WORKQUEUE_N_PRIORITIES]
 
unsigned generation
 
workqueue_reply_t(* update_fn )(void *, void *)
 
void(* free_update_arg_fn )(void *)
 
void ** update_args
 
struct event * reply_event
 
void(* reply_cb )(threadpool_t *)
 
int n_threads
 
int n_threads_max
 
tor_mutex_t lock
 
replyqueue_treply_queue
 
void *(* new_thread_state_fn )(void *)
 
void(* free_thread_state_fn )(void *)
 
void * new_thread_state_arg
 
int exit
 
tor_mutex_t control_lock
 

Detailed Description

A thread-pool manages starting threads and passing work to them.

Definition at line 54 of file workqueue.c.

Field Documentation

◆ condition

tor_cond_t condition

Condition variable that we wait on when we have no work, and which gets signaled when our queue becomes nonempty.

Definition at line 61 of file workqueue.c.

Referenced by threadpool_free_(), threadpool_new(), threadpool_queue_update(), threadpool_queue_work_priority(), threadpool_start_threads(), threadpool_stop_threads(), and worker_thread_main().

◆ control_lock

tor_mutex_t control_lock

Mutex for controlling worker threads' startup and exit.

Definition at line 98 of file workqueue.c.

Referenced by threadpool_free_(), threadpool_new(), threadpool_start_threads(), threadpool_stop_threads(), and worker_thread_main().

◆ exit

int exit

Used for signalling the worker threads to exit.

Definition at line 96 of file workqueue.c.

Referenced by threadpool_new(), threadpool_start_threads(), threadpool_stop_threads(), and worker_thread_main().

◆ free_thread_state_fn

void(* free_thread_state_fn) (void *)

Definition at line 92 of file workqueue.c.

◆ free_update_arg_fn

void(* free_update_arg_fn) (void *)

Function to free update arguments if they can't be run.

Definition at line 73 of file workqueue.c.

Referenced by threadpool_free_(), and threadpool_queue_update().

◆ generation

unsigned generation

The current 'update generation' of the threadpool. Any thread that is at an earlier generation needs to run the update function.

Definition at line 68 of file workqueue.c.

Referenced by threadpool_queue_update(), worker_thread_has_work(), and worker_thread_main().

◆ lock

◆ n_threads

int n_threads

Number of elements in threads.

Definition at line 81 of file workqueue.c.

Referenced by threadpool_free_(), threadpool_get_n_threads(), threadpool_queue_update(), and threadpool_start_threads().

◆ n_threads_max

int n_threads_max

Number of elements to be created in threads.

Definition at line 83 of file workqueue.c.

Referenced by threadpool_start_threads(), and worker_thread_main().

◆ new_thread_state_arg

void* new_thread_state_arg

Definition at line 93 of file workqueue.c.

◆ new_thread_state_fn

void *(* new_thread_state_fn) (void *)

Functions used to allocate and free thread state.

Definition at line 91 of file workqueue.c.

Referenced by threadpool_new(), and threadpool_start_threads().

◆ reply_cb

void(* reply_cb) (threadpool_t *)

Definition at line 78 of file workqueue.c.

◆ reply_event

struct event* reply_event

Event to notice when another thread has sent a reply.

Definition at line 77 of file workqueue.c.

Referenced by threadpool_free_(), and threadpool_register_reply_event().

◆ reply_queue

replyqueue_t* reply_queue

A reply queue to use when constructing new threads.

Definition at line 88 of file workqueue.c.

Referenced by reply_event_cb(), threadpool_free_(), threadpool_get_replyqueue(), threadpool_new(), threadpool_register_reply_event(), and threadpool_start_threads().

◆ threads

struct workerthread_t** threads

An array of pointers to workerthread_t: one for each running worker thread.

Definition at line 57 of file workqueue.c.

Referenced by threadpool_free_(), and threadpool_start_threads().

◆ update_args

void** update_args

Array of n_threads update arguments.

Definition at line 75 of file workqueue.c.

Referenced by threadpool_free_(), threadpool_queue_update(), and worker_thread_main().

◆ update_fn

workqueue_reply_t(* update_fn) (void *, void *)

Function that should be run for updates on each thread.

Definition at line 71 of file workqueue.c.

Referenced by threadpool_queue_update(), and worker_thread_main().

◆ work

work_tailq_t work[WORKQUEUE_N_PRIORITIES]

Queues of pending work that we have to do. The queue with priority p is work[p].

Definition at line 64 of file workqueue.c.

Referenced by queue_reply(), threadpool_new(), threadpool_queue_work_priority(), worker_thread_extract_next_work(), worker_thread_has_work(), and worker_thread_main().


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