diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-07-12 11:47:01 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-07-27 16:28:05 -0400 |
commit | 10e0bff4caba483d971d2a4718a40f62530a66ed (patch) | |
tree | d0e8151c7d92177a2cf5050c2667b0a0ac300a7a /src/test/test_workqueue.c | |
parent | 5636b160d42e344f936f881992c19b3c27f60a2c (diff) | |
download | tor-10e0bff4caba483d971d2a4718a40f62530a66ed.tar.gz tor-10e0bff4caba483d971d2a4718a40f62530a66ed.zip |
Add support for multi-priority workqueues
Each piece of queued work now has an associated priority value; each
priority goes on a separate queue.
With probability (N-1)/N, the workers will take work from the highest
priority nonempty queue. Otherwise, they'll look for work in a
queue of lower priority. This behavior is meant to prevent
starvation for lower-priority tasks.
Diffstat (limited to 'src/test/test_workqueue.c')
-rw-r--r-- | src/test/test_workqueue.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/test/test_workqueue.c b/src/test/test_workqueue.c index 10714457f7..6fa46f90d4 100644 --- a/src/test/test_workqueue.c +++ b/src/test/test_workqueue.c @@ -200,7 +200,9 @@ add_work(threadpool_t *tp) crypto_rand((char*)w->msg, 20); w->msglen = 20; ++rsa_sent; - return threadpool_queue_work(tp, workqueue_do_rsa, handle_reply, w); + return threadpool_queue_work_priority(tp, + WQ_PRI_MED, + workqueue_do_rsa, handle_reply, w); } else { ecdh_work_t *w = tor_malloc_zero(sizeof(*w)); w->serial = n_sent++; |