diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-01-23 19:56:03 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-01-23 19:56:03 +0300 |
commit | de532922d9ab42aa15b40d47c8db53ac2af38500 (patch) | |
tree | d6b7c6b21c7a6e0e3620a3e0c7198e63454d05e3 /src/nxt_work_queue.h | |
parent | 16cbf3c076a0aca6d47adaf3f719493674cf2363 (diff) | |
download | unit-de532922d9ab42aa15b40d47c8db53ac2af38500.tar.gz unit-de532922d9ab42aa15b40d47c8db53ac2af38500.tar.bz2 |
Introducing tasks.
Diffstat (limited to 'src/nxt_work_queue.h')
-rw-r--r-- | src/nxt_work_queue.h | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/src/nxt_work_queue.h b/src/nxt_work_queue.h index 2b168b00..b37fe1a3 100644 --- a/src/nxt_work_queue.h +++ b/src/nxt_work_queue.h @@ -8,6 +8,22 @@ #define _NXT_WORK_QUEUE_H_INCLUDED_ +typedef struct nxt_work_s nxt_work_t; + +typedef struct { + nxt_thread_t *thread; + nxt_log_t *log; + uint32_t ident; + nxt_work_t *next_work; + + /* TODO: exception_handler, prev/next task, subtasks. */ +} nxt_task_t; + + +#define nxt_task_next_ident() \ + ((uint32_t) nxt_atomic_fetch_add(&nxt_task_ident, 1) & 0x3fffffff) + + /* * A work handler with just the obj and data arguments instead * of pointer to a possibly large a work struct allows to call @@ -16,17 +32,15 @@ * source filters, so the data argument has been introduced and * is used where appropriate. */ -typedef void (*nxt_work_handler_t)(nxt_thread_t *thr, void *obj, void *data); - -typedef struct nxt_work_s nxt_work_t; +typedef void (*nxt_work_handler_t)(nxt_task_t *task, void *obj, void *data); struct nxt_work_s { nxt_work_t *next; nxt_work_handler_t handler; + nxt_task_t *task; void *obj; void *data; - nxt_log_t *log; }; @@ -79,24 +93,24 @@ NXT_EXPORT void nxt_thread_work_queue_create(nxt_thread_t *thr, size_t chunk_size); NXT_EXPORT void nxt_thread_work_queue_destroy(nxt_thread_t *thr); NXT_EXPORT void nxt_thread_work_queue_add(nxt_thread_t *thr, - nxt_work_queue_t *wq, - nxt_work_handler_t handler, void *obj, void *data, nxt_log_t *log); + nxt_work_queue_t *wq, nxt_work_handler_t handler, nxt_task_t *task, + void *obj, void *data); NXT_EXPORT void nxt_thread_work_queue_push(nxt_thread_t *thr, - nxt_work_queue_t *wq, nxt_work_handler_t handler, void *obj, void *data, - nxt_log_t *log); + nxt_work_queue_t *wq, nxt_work_handler_t handler, nxt_task_t *task, + void *obj, void *data); NXT_EXPORT void nxt_work_queue_attach(nxt_thread_t *thr, nxt_work_queue_t *wq); NXT_EXPORT nxt_work_handler_t nxt_thread_work_queue_pop(nxt_thread_t *thr, - void **obj, void **data, nxt_log_t **log); + nxt_task_t **task, void **obj, void **data); NXT_EXPORT void nxt_thread_work_queue_drop(nxt_thread_t *thr, void *data); #define \ -nxt_thread_current_work_queue_add(thr, handler, obj, data, log) \ +nxt_thread_current_work_queue_add(thr, handler, task, obj, data) \ do { \ nxt_thread_t *_thr = thr; \ \ nxt_thread_work_queue_add(_thr, _thr->work_queue.head, \ - handler, obj, data, log); \ + handler, task, obj, data); \ } while (0) @@ -118,18 +132,18 @@ nxt_work_queue_name(_wq, _name) NXT_EXPORT void nxt_thread_last_work_queue_add(nxt_thread_t *thr, - nxt_work_handler_t handler, void *obj, void *data, nxt_log_t *log); + nxt_work_handler_t handler, void *obj, void *data); NXT_EXPORT nxt_work_handler_t nxt_thread_last_work_queue_pop(nxt_thread_t *thr, - void **obj, void **data, nxt_log_t **log); + nxt_task_t **task, void **obj, void **data); NXT_EXPORT void nxt_locked_work_queue_create(nxt_locked_work_queue_t *lwq, size_t chunk_size); NXT_EXPORT void nxt_locked_work_queue_destroy(nxt_locked_work_queue_t *lwq); NXT_EXPORT void nxt_locked_work_queue_add(nxt_locked_work_queue_t *lwq, - nxt_work_handler_t handler, void *obj, void *data, nxt_log_t *log); + nxt_work_handler_t handler, nxt_task_t *task, void *obj, void *data); NXT_EXPORT nxt_work_handler_t nxt_locked_work_queue_pop( - nxt_locked_work_queue_t *lwq, void **obj, void **data, nxt_log_t **log); + nxt_locked_work_queue_t *lwq, nxt_task_t **task, void **obj, void **data); NXT_EXPORT void nxt_locked_work_queue_move(nxt_thread_t *thr, nxt_locked_work_queue_t *lwq, nxt_work_queue_t *wq); |