mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-30 07:11:04 +01:00
MEDIUM: task: only keep task_new_*() and drop task_new()
As previously advertised in comments, the mask-based task_new() is now gone. The low-level function now is task_new_on() which takes a thread number or a negative value for "any thread", which is turned to zero for thread-less builds since there's no shared WQ in thiscase. The task_new_here() and task_new_anywhere() functions were adjusted accordingly.
This commit is contained in:
parent
cb8542755e
commit
1f4bf7215a
@ -535,20 +535,20 @@ static inline void tasklet_remove_from_tasklet_list(struct tasklet *t)
|
|||||||
/*
|
/*
|
||||||
* Initialize a new task. The bare minimum is performed (queue pointers and
|
* Initialize a new task. The bare minimum is performed (queue pointers and
|
||||||
* state). The task is returned. This function should not be used outside of
|
* state). The task is returned. This function should not be used outside of
|
||||||
* task_new(). If the thread mask contains more than one thread, TASK_SHARED_WQ
|
* task_new(). If the thread ID is < 0, the task may run on any thread.
|
||||||
* is set.
|
|
||||||
*/
|
*/
|
||||||
static inline struct task *task_init(struct task *t, unsigned long thread_mask)
|
static inline struct task *task_init(struct task *t, int tid)
|
||||||
{
|
{
|
||||||
t->wq.node.leaf_p = NULL;
|
t->wq.node.leaf_p = NULL;
|
||||||
t->rq.node.leaf_p = NULL;
|
t->rq.node.leaf_p = NULL;
|
||||||
t->state = TASK_SLEEPING;
|
t->state = TASK_SLEEPING;
|
||||||
if (atleast2(thread_mask)) {
|
#ifndef USE_THREAD
|
||||||
|
/* no shared wq without threads */
|
||||||
|
tid = 0;
|
||||||
|
#endif
|
||||||
|
t->tid = tid;
|
||||||
|
if (tid < 0)
|
||||||
t->state |= TASK_SHARED_WQ;
|
t->state |= TASK_SHARED_WQ;
|
||||||
t->tid = -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
t->tid = my_ffsl(thread_mask) - 1;
|
|
||||||
t->nice = 0;
|
t->nice = 0;
|
||||||
t->calls = 0;
|
t->calls = 0;
|
||||||
t->call_date = 0;
|
t->call_date = 0;
|
||||||
@ -591,38 +591,29 @@ static inline struct tasklet *tasklet_new(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate and initialise a new task. The new task is returned, or NULL in
|
* Allocate and initialize a new task, to run on global thread <thr>, or any
|
||||||
* case of lack of memory. The task count is incremented. This API might change
|
* thread if negative. The task count is incremented. The new task is returned,
|
||||||
* in the near future, so prefer one of the task_new_*() wrappers below which
|
* or NULL in case of lack of memory. It's up to the caller to pass a valid
|
||||||
* are usually more suitable. Tasks must be freed using task_free().
|
* thread number (in tid space, 0 to nbthread-1, or <0 for any). Tasks created
|
||||||
|
* this way must be freed using task_destroy().
|
||||||
*/
|
*/
|
||||||
static inline struct task *task_new(unsigned long thread_mask)
|
static inline struct task *task_new_on(int thr)
|
||||||
{
|
{
|
||||||
struct task *t = pool_alloc(pool_head_task);
|
struct task *t = pool_alloc(pool_head_task);
|
||||||
if (t) {
|
if (t) {
|
||||||
th_ctx->nb_tasks++;
|
th_ctx->nb_tasks++;
|
||||||
task_init(t, thread_mask);
|
task_init(t, thr);
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate and initialize a new task, to run on global thread <thr>. The new
|
|
||||||
* task is returned, or NULL in case of lack of memory. It's up to the caller
|
|
||||||
* to pass a valid thread number (in tid space, 0 to nbthread-1). The task
|
|
||||||
* count is incremented.
|
|
||||||
*/
|
|
||||||
static inline struct task *task_new_on(uint thr)
|
|
||||||
{
|
|
||||||
return task_new(1UL << thr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate and initialize a new task, to run on the calling thread. The new
|
/* Allocate and initialize a new task, to run on the calling thread. The new
|
||||||
* task is returned, or NULL in case of lack of memory. The task count is
|
* task is returned, or NULL in case of lack of memory. The task count is
|
||||||
* incremented.
|
* incremented.
|
||||||
*/
|
*/
|
||||||
static inline struct task *task_new_here()
|
static inline struct task *task_new_here()
|
||||||
{
|
{
|
||||||
return task_new(tid_bit);
|
return task_new_on(tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate and initialize a new task, to run on any thread. The new task is
|
/* Allocate and initialize a new task, to run on any thread. The new task is
|
||||||
@ -630,7 +621,7 @@ static inline struct task *task_new_here()
|
|||||||
*/
|
*/
|
||||||
static inline struct task *task_new_anywhere()
|
static inline struct task *task_new_anywhere()
|
||||||
{
|
{
|
||||||
return task_new(all_threads_mask);
|
return task_new_on(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user