workqueue.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 threadpool_queue_for_all(threadpool_t *pool,
  19. void *(*dup_fn)(void *),
  20. int (*fn)(void *, void *),
  21. void (*reply_fn)(void *),
  22. void *arg);
  23. int workqueue_entry_cancel(workqueue_entry_t *pending_work);
  24. threadpool_t *threadpool_new(int n_threads,
  25. replyqueue_t *replyqueue,
  26. void *(*new_thread_state_fn)(void*),
  27. void (*free_thread_state_fn)(void*),
  28. void *arg);
  29. replyqueue_t *threadpool_get_replyqueue(threadpool_t *tp);
  30. replyqueue_t *replyqueue_new(void);
  31. tor_socket_t replyqueue_get_socket(replyqueue_t *rq);
  32. void replyqueue_process(replyqueue_t *queue);
  33. #endif