workqueue.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /* Copyright (c) 2013, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. #ifndef TOR_WORKQUEUE_H
  4. #define TOR_WORKQUEUE_H
  5. #include "compat.h"
  6. typedef struct replyqueue_s replyqueue_t;
  7. typedef struct threadpool_s threadpool_t;
  8. typedef struct workqueue_entry_s workqueue_entry_t;
  9. #define WQ_CMD_RUN 0
  10. #define WQ_CMD_CANCEL 1
  11. #define WQ_RPL_REPLY 0
  12. #define WQ_RPL_ERROR 1
  13. #define WQ_RPL_SHUTDOWN 2
  14. workqueue_entry_t *threadpool_queue_work(threadpool_t *pool,
  15. int (*fn)(void *, void *),
  16. void (*reply_fn)(void *),
  17. void *arg);
  18. int workqueue_entry_cancel(workqueue_entry_t *pending_work);
  19. int threadpool_start_threads(threadpool_t *pool, int n);
  20. threadpool_t *threadpool_new(int n_threads,
  21. replyqueue_t *replyqueue,
  22. void *(*new_thread_state_fn)(void*),
  23. void (*free_thread_state_fn)(void*),
  24. void *arg);
  25. replyqueue_t *threadpool_get_replyqueue(threadpool_t *tp);
  26. replyqueue_t *replyqueue_new(void);
  27. tor_socket_t replyqueue_get_socket(replyqueue_t *rq);
  28. void replyqueue_process(replyqueue_t *queue);
  29. #endif