Skip to content

Commit 0334cb2

Browse files
committed
MINOR: tasklet: make the low-level tasklet API take a flag
Everything in the tasklet layer supports flags, except that they are just not implemented in the wakeup functions, while they are in the task_wakeup functions. Initially it was not considered useful to pass wakeup causes because these were essentially I/O, but with the growing number of I/O handlers having to deal with various types of operations (typically cheap I/O notifications on subscribe vs heavy parsing on application-level wakeups), it would be nice to start to make this distinction possible. This commit extends _tasklet_wakeup_on() and _tasklet_wakeup_after() to pass a set of flags that continues to be set as zero. For now this changes nothing, but new functions will come.
1 parent e57581d commit 0334cb2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

include/haproxy/task.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,11 @@ static inline void task_set_thread(struct task *t, int thr)
375375
* purposes.
376376
*/
377377
#define tasklet_wakeup_on(tl, thr) \
378-
_tasklet_wakeup_on(tl, thr, MK_CALLER(WAKEUP_TYPE_TASKLET_WAKEUP, 0, 0))
378+
_tasklet_wakeup_on(tl, thr, 0, MK_CALLER(WAKEUP_TYPE_TASKLET_WAKEUP, 0, 0))
379379

380-
static inline void _tasklet_wakeup_on(struct tasklet *tl, int thr, const struct ha_caller *caller)
380+
static inline void _tasklet_wakeup_on(struct tasklet *tl, int thr, uint f, const struct ha_caller *caller)
381381
{
382-
unsigned int state = tl->state;
382+
unsigned int state = _HA_ATOMIC_OR_FETCH(&tl->state, f);
383383

384384
do {
385385
/* do nothing if someone else already added it */
@@ -407,7 +407,7 @@ static inline void _tasklet_wakeup_on(struct tasklet *tl, int thr, const struct
407407
* task for tracing purposes.
408408
*/
409409
#define tasklet_wakeup(tl) \
410-
_tasklet_wakeup_on(tl, (tl)->tid, MK_CALLER(WAKEUP_TYPE_TASKLET_WAKEUP, 0, 0))
410+
_tasklet_wakeup_on(tl, (tl)->tid, 0, MK_CALLER(WAKEUP_TYPE_TASKLET_WAKEUP, 0, 0))
411411

412412
/* instantly wakes up task <t> on its owner thread even if it's not the current
413413
* one, bypassing the run queue. The purpose is to be able to avoid contention
@@ -468,12 +468,12 @@ static inline void _task_instant_wakeup(struct task *t, unsigned int f, const st
468468
* for tracing purposes.
469469
*/
470470
#define tasklet_wakeup_after(head, tl) \
471-
_tasklet_wakeup_after(head, tl, MK_CALLER(WAKEUP_TYPE_TASKLET_WAKEUP_AFTER, 0, 0))
471+
_tasklet_wakeup_after(head, tl, 0, MK_CALLER(WAKEUP_TYPE_TASKLET_WAKEUP_AFTER, 0, 0))
472472

473473
static inline struct list *_tasklet_wakeup_after(struct list *head, struct tasklet *tl,
474-
const struct ha_caller *caller)
474+
uint f, const struct ha_caller *caller)
475475
{
476-
unsigned int state = tl->state;
476+
unsigned int state = _HA_ATOMIC_OR_FETCH(&tl->state, f);
477477

478478
do {
479479
/* do nothing if someone else already added it */

0 commit comments

Comments
 (0)