[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Expand cpuworker API to allow other work types
commit b022ea32a685e4163595b5a3ded0bc00bb378896
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Thu Apr 6 15:51:52 2017 -0400
Expand cpuworker API to allow other work types
---
src/common/workqueue.h | 2 +-
src/or/cpuworker.c | 14 ++++++++++++++
src/or/cpuworker.h | 6 ++++++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/common/workqueue.h b/src/common/workqueue.h
index 5d14e7f..7b483eb 100644
--- a/src/common/workqueue.h
+++ b/src/common/workqueue.h
@@ -16,7 +16,7 @@ typedef struct threadpool_s threadpool_t;
typedef struct workqueue_entry_s workqueue_entry_t;
/** Possible return value from a work function: */
-typedef enum {
+typedef enum workqueue_reply_t {
WQ_RPL_REPLY = 0, /** indicates success */
WQ_RPL_ERROR = 1, /** indicates fatal error */
WQ_RPL_SHUTDOWN = 2, /** indicates thread is shutting down */
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c
index 790c147..f79cd06 100644
--- a/src/or/cpuworker.c
+++ b/src/or/cpuworker.c
@@ -479,6 +479,20 @@ queue_pending_tasks(void)
}
}
+/** DOCDOC */
+workqueue_entry_t *
+cpuworker_queue_work(workqueue_reply_t (*fn)(void *, void *),
+ void (*reply_fn)(void *),
+ void *arg)
+{
+ tor_assert(threadpool);
+
+ return threadpool_queue_work(threadpool,
+ fn,
+ reply_fn,
+ arg);
+}
+
/** Try to tell a cpuworker to perform the public key operations necessary to
* respond to <b>onionskin</b> for the circuit <b>circ</b>.
*
diff --git a/src/or/cpuworker.h b/src/or/cpuworker.h
index fd426e2..9bc5d96 100644
--- a/src/or/cpuworker.h
+++ b/src/or/cpuworker.h
@@ -14,6 +14,12 @@
void cpu_init(void);
void cpuworkers_rotate_keyinfo(void);
+struct workqueue_entry_s;
+enum workqueue_reply_t;
+struct workqueue_entry_s *cpuworker_queue_work(
+ enum workqueue_reply_t (*fn)(void *, void *),
+ void (*reply_fn)(void *),
+ void *arg);
struct create_cell_t;
int assign_onionskin_to_cpuworker(or_circuit_t *circ,
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits