summaryrefslogtreecommitdiff
path: root/src/threadpool.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/threadpool.h')
-rw-r--r--src/threadpool.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/threadpool.h b/src/threadpool.h
index 91c903c..61dbacd 100644
--- a/src/threadpool.h
+++ b/src/threadpool.h
@@ -25,7 +25,7 @@ typedef struct ctqueue ctqueue;
25 * @param callback Callback function the given data should be ran with. Must be non-null 25 * @param callback Callback function the given data should be ran with. Must be non-null
26 * @param freecb Callback function for freeing the given data. May be null 26 * @param freecb Callback function for freeing the given data. May be null
27 * @param data Data to be passed to the callback. May be null 27 * @param data Data to be passed to the callback. May be null
28 * @return task* Returns a task object with set parameters. Returns `null` and sets errno on error 28 * @retval (task*)[NULL, task*] Returns a task object with set parameters. Returns `null` and sets errno on error
29 */ 29 */
30task * task_init(gcallback callback, fcallback freecb, void *data); 30task * task_init(gcallback callback, fcallback freecb, void *data);
31 31
@@ -40,7 +40,7 @@ void task_free(void *tsk);
40 * @brief Fire a task. Passes the `data` member to the specified `callback` 40 * @brief Fire a task. Passes the `data` member to the specified `callback`
41 * 41 *
42 * @param tsk A task to be fired. Must be non-null 42 * @param tsk A task to be fired. Must be non-null
43 * @return int Returns value of the fired callback. Returns -1 and sets errno on error 43 * @retval (int) Returns value of the fired callback. Returns -1 and sets errno on error
44 */ 44 */
45int task_fire(task *tsk); 45int task_fire(task *tsk);
46 46
@@ -48,7 +48,7 @@ int task_fire(task *tsk);
48 * @brief Fire and destroy a task simultaneously. Calls specified callback and free-callback on associated data 48 * @brief Fire and destroy a task simultaneously. Calls specified callback and free-callback on associated data
49 * 49 *
50 * @param tsk Task to be fired and destroyed. Must be non-null 50 * @param tsk Task to be fired and destroyed. Must be non-null
51 * @return int Returns value of the callback. Returns -1 and sets errno on error 51 * @retval (int) Returns value of the callback. Returns -1 and sets errno on error
52 */ 52 */
53int task_fired(task *tsk); 53int task_fired(task *tsk);
54 54
@@ -57,7 +57,7 @@ int task_fired(task *tsk);
57/** 57/**
58 * @brief Create a FIFO queue of tasks 58 * @brief Create a FIFO queue of tasks
59 * 59 *
60 * @return taskqueue* Returns a new taskqueue object. Returns `null` and sets errno on error 60 * @retval (taskqueue*)[NULL, taskqueue*] Returns a new taskqueue object. Returns `null` and sets errno on error
61 */ 61 */
62taskqueue * taskqueue_init(void); 62taskqueue * taskqueue_init(void);
63 63
@@ -73,7 +73,7 @@ void taskqueue_free(void *tq);
73 * 73 *
74 * @param tq The taskqueue to be modified. Must be non-null 74 * @param tq The taskqueue to be modified. Must be non-null
75 * @param tsk The task to push. Must be non-null 75 * @param tsk The task to push. Must be non-null
76 * @return int Returns 0 on success, sets errno and returns -1 on error 76 * @retval (int)[-1, 0] Returns 0 on success, sets errno and returns -1 on error
77 */ 77 */
78int taskqueue_push(taskqueue *tq, task *tsk); 78int taskqueue_push(taskqueue *tq, task *tsk);
79 79
@@ -81,7 +81,7 @@ int taskqueue_push(taskqueue *tq, task *tsk);
81 * @brief Pop a task from a taskqueue 81 * @brief Pop a task from a taskqueue
82 * 82 *
83 * @param tq A taskqueue to grab a task from. Must be non-null 83 * @param tq A taskqueue to grab a task from. Must be non-null
84 * @return task* Returns a task on success, sets errno and returns `null` on error 84 * @retval (task*)[NULL, task*] Returns a task on success, sets errno and returns `null` on error
85 */ 85 */
86task * taskqueue_pop(taskqueue *tq); 86task * taskqueue_pop(taskqueue *tq);
87 87
@@ -90,7 +90,7 @@ task * taskqueue_pop(taskqueue *tq);
90 * 90 *
91 * @param tq The taskqueue to be modified. Must be non-null 91 * @param tq The taskqueue to be modified. Must be non-null
92 * @param tsk The task to be appended. Must be non-null 92 * @param tsk The task to be appended. Must be non-null
93 * @return int Returns 0 on success, sets errno and returns `null` on error 93 * @retval (int)[-1, 0] Returns 0 on success, sets errno and returns -1 on error
94 */ 94 */
95int taskqueue_pushfront(taskqueue *tq, task *tsk); 95int taskqueue_pushfront(taskqueue *tq, task *tsk);
96 96
@@ -98,7 +98,7 @@ int taskqueue_pushfront(taskqueue *tq, task *tsk);
98 * @brief Pop a task from the back (most recently pushed task) of a taskqueue 98 * @brief Pop a task from the back (most recently pushed task) of a taskqueue
99 * 99 *
100 * @param tq A taskqueue to pop from. Must be non-null 100 * @param tq A taskqueue to pop from. Must be non-null
101 * @return task* Returns a task on success, sets errno and returns `null` on error 101 * @retval (task*)[NULL, task*] Returns a task on success, sets errno and returns `null` on error
102 */ 102 */
103task * taskqueue_popback(taskqueue *tq); 103task * taskqueue_popback(taskqueue *tq);
104 104
@@ -108,7 +108,7 @@ task * taskqueue_popback(taskqueue *tq);
108 * @brief Create a concurrent taskqueue with `size` allocated threads 108 * @brief Create a concurrent taskqueue with `size` allocated threads
109 * 109 *
110 * @param size Number of threads in the threadpool. Must be greater than zero 110 * @param size Number of threads in the threadpool. Must be greater than zero
111 * @return ctqueue* Returns a new ctqueue, sets errno and returns `null` on error 111 * @retval (ctqueue*)[NULL, ctqueue*] Returns a new ctqueue, sets errno and returns `null` on error
112 */ 112 */
113ctqueue * ctqueue_init(int size); 113ctqueue * ctqueue_init(int size);
114 114
@@ -116,7 +116,7 @@ ctqueue * ctqueue_init(int size);
116 * @brief Cancel all tasks being processed in a currently running concurrent taskqueue 116 * @brief Cancel all tasks being processed in a currently running concurrent taskqueue
117 * 117 *
118 * @param ctq The concurrent taskqueue to be canceled. Must be non-null 118 * @param ctq The concurrent taskqueue to be canceled. Must be non-null
119 * @return int Returns 0 on success, sets errno and returns -1 on error 119 * @retval (int)[-1, 0] Returns 0 on success, sets errno and returns -1 on error
120 */ 120 */
121int ctqueue_cancel(ctqueue *ctq); 121int ctqueue_cancel(ctqueue *ctq);
122 122
@@ -134,7 +134,7 @@ void ctqueue_free(void *ctq);
134 * 134 *
135 * @param ctq The concurrent taskqueue to modify. Must be non-null 135 * @param ctq The concurrent taskqueue to modify. Must be non-null
136 * @param tsk The task to push. Must be non-null 136 * @param tsk The task to push. Must be non-null
137 * @return Returns `thrd_success` on success, returns `thrd_error` or `thrd_nomem` on error 137 * @retval (int) Returns `thrd_success` on success, returns `thrd_error` or `thrd_nomem` on error
138 */ 138 */
139int ctqueue_waitpush(ctqueue *ctq, task *tsk); 139int ctqueue_waitpush(ctqueue *ctq, task *tsk);
140 140
@@ -144,7 +144,7 @@ int ctqueue_waitpush(ctqueue *ctq, task *tsk);
144 * @attention May block for an indefinite amount of time to pop the task 144 * @attention May block for an indefinite amount of time to pop the task
145 * 145 *
146 * @param ctq The concurrent taskqueue to pop from. Must be non-null 146 * @param ctq The concurrent taskqueue to pop from. Must be non-null
147 * @return Returns a task on success, sets errno and returns `null` on error 147 * @retval (task*)[NULL, task*] Returns a task on success, sets errno and returns `null` on error
148 */ 148 */
149task * ctqueue_waitpop(ctqueue *ctq); 149task * ctqueue_waitpop(ctqueue *ctq);
150 150
@@ -153,7 +153,7 @@ task * ctqueue_waitpop(ctqueue *ctq);
153 * @attention Threads will not consume pushed tasks until this function is ran 153 * @attention Threads will not consume pushed tasks until this function is ran
154 * 154 *
155 * @param ctq A concurrent taskqueue to start. Must be non-null 155 * @param ctq A concurrent taskqueue to start. Must be non-null
156 * @return int Returns 0 on success, sets errno and returns -1 on error 156 * @retval (int)[-1, 0] Returns 0 on success, sets errno and returns -1 on error
157 */ 157 */
158int ctqueue_start(ctqueue *ctq); 158int ctqueue_start(ctqueue *ctq);
159 159