tor  0.4.2.0-alpha-dev
workqueue.h
Go to the documentation of this file.
1 /* Copyright (c) 2013-2019, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
9 #ifndef TOR_WORKQUEUE_H
10 #define TOR_WORKQUEUE_H
11 
12 #include "lib/cc/torint.h"
13 
16 typedef struct replyqueue_s replyqueue_t;
18 typedef struct threadpool_s threadpool_t;
22 
24 typedef enum workqueue_reply_t {
25  WQ_RPL_REPLY = 0,
29 
31 typedef enum workqueue_priority_t {
32  WQ_PRI_HIGH = 0,
33  WQ_PRI_MED = 1,
34  WQ_PRI_LOW = 2,
36 
39  workqueue_reply_t (*fn)(void *,
40  void *),
41  void (*reply_fn)(void *),
42  void *arg);
43 
45  workqueue_reply_t (*fn)(void *,
46  void *),
47  void (*reply_fn)(void *),
48  void *arg);
49 
51  void *(*dup_fn)(void *),
52  workqueue_reply_t (*fn)(void *, void *),
53  void (*free_fn)(void *),
54  void *arg);
55 void *workqueue_entry_cancel(workqueue_entry_t *pending_work);
56 threadpool_t *threadpool_new(int n_threads,
57  replyqueue_t *replyqueue,
58  void *(*new_thread_state_fn)(void*),
59  void (*free_thread_state_fn)(void*),
60  void *arg);
62 
63 replyqueue_t *replyqueue_new(uint32_t alertsocks_flags);
64 void replyqueue_process(replyqueue_t *queue);
65 
67  void (*cb)(threadpool_t *tp));
68 
69 #endif /* !defined(TOR_WORKQUEUE_H) */
workqueue_entry_t * threadpool_queue_work(threadpool_t *pool, workqueue_reply_t(*fn)(void *, void *), void(*reply_fn)(void *), void *arg)
Definition: workqueue.c:413
workqueue_reply_t
Definition: workqueue.h:24
workqueue_priority_t
Definition: workqueue.h:31
Integer definitions used throughout Tor.
void * workqueue_entry_cancel(workqueue_entry_t *pending_work)
Definition: workqueue.c:191
workqueue_entry_t * threadpool_queue_work_priority(threadpool_t *pool, workqueue_priority_t prio, workqueue_reply_t(*fn)(void *, void *), void(*reply_fn)(void *), void *arg)
Definition: workqueue.c:386
int threadpool_register_reply_event(threadpool_t *tp, void(*cb)(threadpool_t *tp))
Definition: workqueue.c:623
int threadpool_queue_update(threadpool_t *pool, void *(*dup_fn)(void *), workqueue_reply_t(*fn)(void *, void *), void(*free_fn)(void *), void *arg)
Definition: workqueue.c:437
replyqueue_t * replyqueue_new(uint32_t alertsocks_flags)
Definition: workqueue.c:586
Definition: workqueue.c:95
threadpool_t * threadpool_new(int n_threads, replyqueue_t *replyqueue, void *(*new_thread_state_fn)(void *), void(*free_thread_state_fn)(void *), void *arg)
Definition: workqueue.c:541
replyqueue_t * threadpool_get_replyqueue(threadpool_t *tp)
Definition: workqueue.c:576
void replyqueue_process(replyqueue_t *queue)
Definition: workqueue.c:647