]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Expand cpuworker API to allow other work types
authorNick Mathewson <nickm@torproject.org>
Thu, 6 Apr 2017 19:51:52 +0000 (15:51 -0400)
committerNick Mathewson <nickm@torproject.org>
Sat, 15 Apr 2017 15:21:33 +0000 (11:21 -0400)
src/common/workqueue.h
src/or/cpuworker.c
src/or/cpuworker.h

index 5d14e7f6a77b1afbe8f2c3eae5936af4131d0dee..7b483eb7ac7a29a20faed04889b476cce01aed2b 100644 (file)
@@ -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 */
index 790c147d7b86fa6f252a463e85223ba88fcbe7be..f79cd067cb1508b44e8f46bdca2acd56a0188c48 100644 (file)
@@ -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>.
  *
index fd426e21f6599f540f49b8a6579c588c0a59fef6..9bc5d962dd140e4ec8fb0aab1113c8cf7f36005b 100644 (file)
 
 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,